Skip to content

Commit

Permalink
Merge pull request #278 from Dans-Plugins/release/v1.7
Browse files Browse the repository at this point in the history
Release/v1.7
  • Loading branch information
dmccoystephenson authored Mar 24, 2024
2 parents baa0b28 + 6c8fb0c commit fc862f8
Show file tree
Hide file tree
Showing 24 changed files with 520 additions and 179 deletions.
8 changes: 8 additions & 0 deletions .devcontainer/resources/ops.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"uuid": "0a9fa342-3139-49d7-8acb-fcf4d9c1f0ef",
"name": "DanTheTechMan",
"level": 4,
"bypassesPlayerLimit": false
}
]
22 changes: 22 additions & 0 deletions .devcontainer/resources/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
echo "Running 'post-create.sh' script..."
if [ -z "$(ls -A /testmcserver)" ]; then
echo "Setting up server..."
# Copy server JAR
cp /testmcserver-build/spigot-1.20.4.jar /testmcserver/spigot-1.20.4.jar

# Create plugins directory
mkdir /testmcserver/plugins

# Install Wild Pets
cp /wp-build/target/WildPets-1.7.0-SNAPSHOT.jar /testmcserver/plugins

# Copy config files
cp /resources/ops.json /testmcserver

# Accept EULA
cd /testmcserver && echo "eula=true" > eula.txt
else
echo "Server is already set up."
fi

java -jar /testmcserver/spigot-1.20.4.jar
84 changes: 64 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,64 @@
# Contributing To The Project
## Thank You
Thank you so much for being willing to contribute to this project! Please feel free to fork the repository and contact me on my [support discord server](https://discord.gg/xXtuAQ2).

## Some Things To Know
- We use ZenHub to manage repository issues.
- Our highest priority issues will be put in the 'Next Release' pipeline.

## Process
- When you start working on something, move the task/improvement/bug into the 'In Progress' pipeline and assign it to yourself.
- When you're finished with something, move the associated issues into the 'Done' pipeline and open a pull request and assign it to yourself.
- When your pull request is reviewed and merged, close the associated issues.

## Caveats
- If you start working on something, please remember to assign yourself to the related issues so I know what is being worked on.
- If you assign yourself an epic, assign yourself all tasks under that epic.
- Only move an epic associated with one or more tasks into the 'In Progress' when all tasks left to do are assigned to you.

## Bugs
- When you encounter a bug that is in the code of the master branch, create an issue for it and assign it the 'Bug' label.
# Contributing Document
## Thank You
Thank you for being interested in contributing to the project! It wouldn't be where it is today without the help of the community. This document will help you get started with contributing to the project.

## Links
- [Website](https://dansplugins.com)
- [Discord](https://discord.gg/xXtuAQ2)

## Requirements
- A GitHub account
- Git installed on your local machine
- A text editor or IDE
- A basic understanding of Java

## Getting Started
- If you don't already have a GitHub account, you can sign up for one [here](https://github.com/signup).
- Fork the repository on GitHub by clicking the "Fork" button on the top right of the repository page.
- Clone your fork of the repository to your local machine using `git clone https://www.github.com/<your-username>/Wild-Pets.git`
- Open the project in your preferred text editor or IDE.
- Try compiling the plugin using the following command:
```bash
gradlew build
```
If you encounter any errors, please create an issue for it.

## Identifying What To Work On
### Issues
Work items are tracked as GitHub issues. You can find a full list of issues [here](https://github.com/Dans-Plugins/Wild-Pets/issues).

### Milestones
Work items are organized into milestones, which represent a specific version of the plugin. You can find the milestones [here](https://github.com/Dans-Plugins/Wild-Pets/milestones).

## Making Changes
- Before you start working on something, make sure there is an issue for it. If there isn't, create one.
- Make sure you are working on the "develop" branch. If you are not, switch to it using `git checkout develop`.
- Create a new branch for your changes using `git checkout -b <branch-name>`. Make sure to name your branch something that is related to the issue you are working on.
- Make your changes to the code.
- Test your changes to make sure they work as expected. [More information on testing can be found here](#testing).
- When you are finished, commit your changes using `git commit -m "Your commit message here"`.
- Push your changes to your fork using `git push origin <branch-name>`.
- Open a pull request on the original repository. Make sure to include a description of your changes and link the related issue using #(number). The develop branch should be used as the base branch.
- Wait for your pull request to be reviewed. If there are any changes that need to be made, make them and push the changes to your fork. Your pull request will be updated automatically.
- Once your pull request has been reviewed and approved, it will be merged into the develop branch.

## Testing
The unit tests can be executed by reopening the project in the provided dev container & running 'mvn test'. Additionally, you can test your changes by running the plugin on a Spigot server.

### Running a Spigot server with Docker
If you don't have Docker installed, you can download it [here](https://www.docker.com/products/docker-desktop).

To run a Spigot server with Docker, you can use the following command:
```bash
docker compose up
```

This will start a Spigot server on your local machine. You can connect to it using the IP `localhost` and the port `25565`.

If you make changes to the code, you can deploy the latest changes by rebuilding the Docker image:
```bash
docker compose up --build
```

## Questions
If you have any questions about contributing to the project, feel free to ask in the Discord server. You can join the Discord server [here](https://discord.gg/xXtuAQ2). This is the best place to ask questions.
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ RUN apt-get install -y git \
wget \
maven

# Create server directory
WORKDIR /testmcserver

# Build server
WORKDIR /testmcserver-build
RUN wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
RUN git config --global --unset core.autocrlf || :
RUN java -jar BuildTools.jar --rev 1.20.4
RUN echo "eula=true" > eula.txt
RUN mkdir plugins

# Build plugin
WORKDIR /wp-build
COPY . .
RUN mvn clean package
RUN cp target/WildPets-*.jar plugins
RUN mvn package

# Copy resources and make post-create.sh executable
COPY ./.devcontainer/resources /resources
RUN chmod +x /resources/post-create.sh

# Run server
WORKDIR /testmcserver
EXPOSE 25565
ENTRYPOINT java -jar spigot-1.20.4.jar
ENTRYPOINT /resources/post-create.sh
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ Please fill out a bug report [here](https://github.com/dmccoystephenson/Wild-Pet
- [Planned Improvements](https://github.com/dmccoystephenson/Wild-Pets/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement)

## Contributing
- [Notes for Developers (coming soon)](https://github.com/dmccoystephenson/Wild-Pets/wiki/Developer-Notes)
- [Contributing.md](https://github.com/dmccoystephenson/Medieval-Factions/blob/master/CONTRIBUTING.md)

## Testing
The unit tests can be executed by reopening the project in the provided dev container & running `mvn test`.

## Authors and acknowledgement
Name | Main Contributions
------------ | -------------
Daniel Stephenson | Creator

I created this plugin because one of my players, [TheeFallen100](https://www.planetminecraft.com/member/theefallen), said they wished they could tame a fox. When I mentioned I could make a plugin that could accomplish that, they suggested I name it Wild Pets.
This plugin was developed in response to a player request from TheeFallen100, who expressed a desire to tame foxes in the game. Upon proposing the idea of creating such a plugin, they suggested the name Wild Pets.

## License
GPL3
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dansplugins</groupId>
<artifactId>WildPets</artifactId>
<version>1.6.0</version>
<version>1.7.0</version>
<packaging>jar</packaging>

<name>Wild Pets</name>
Expand Down Expand Up @@ -80,5 +80,11 @@
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion src/main/java/dansplugins/wildpets/WildPets.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public final class WildPets extends PonderBukkitPlugin {
private final EphemeralData ephemeralData = new EphemeralData();
private final EntityConfigService entityConfigService = new EntityConfigService(this);
private final ConfigService configService = new ConfigService(this, entityConfigService);
private final PetListRepository petListRepository = new PetListRepository(this, configService);
private final PetListRepository petListRepository = new PetListRepository(configService);
private final PetRecordRepository petRecordRepository = new PetRecordRepository();
private final StorageService storageService = new StorageService(configService, this, petListRepository, petRecordRepository);
private final Scheduler scheduler = new Scheduler(this, ephemeralData, storageService);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dansplugins/wildpets/commands/InfoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dansplugins.wildpets.config.ConfigService;
import dansplugins.wildpets.data.EphemeralData;
import dansplugins.wildpets.info.InfoSender;
import dansplugins.wildpets.pet.Pet;
import dansplugins.wildpets.pet.record.PetRecordRepository;
import preponderous.ponder.minecraft.bukkit.abs.AbstractPluginCommand;
Expand Down Expand Up @@ -41,7 +42,8 @@ public boolean execute(CommandSender sender) {
return false;
}

pet.sendInfoToPlayer(player, configService, petRecordRepository);
InfoSender infoSender = new InfoSender(configService, petRecordRepository);
infoSender.sendInfoToPlayer(player, pet);
return true;
}

Expand Down
16 changes: 15 additions & 1 deletion src/main/java/dansplugins/wildpets/commands/LocateCommand.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package dansplugins.wildpets.commands;

import dansplugins.wildpets.data.EphemeralData;
import dansplugins.wildpets.location.WpLocation;
import dansplugins.wildpets.pet.Pet;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import preponderous.ponder.minecraft.bukkit.abs.AbstractPluginCommand;

import org.bukkit.ChatColor;
Expand Down Expand Up @@ -35,7 +39,17 @@ public boolean execute(CommandSender sender) {
return false;
}

pet.sendLocationToPlayer(player);
Entity entity = Bukkit.getEntity(pet.getUniqueID());

if (entity != null) {
Location bukkitLocation = entity.getLocation();
WpLocation wpLocation = new WpLocation(bukkitLocation.getX(), bukkitLocation.getY(), bukkitLocation.getZ());
pet.setLastKnownLocation(wpLocation);
}

WpLocation lastKnownLocation = pet.getLastKnownLocation();

player.sendMessage(ChatColor.AQUA + pet.getName() + String.format("'s last known location is (%s, %s, %s).", lastKnownLocation.getX(), lastKnownLocation.getY(), lastKnownLocation.getZ()));
return true;
}

Expand Down
24 changes: 23 additions & 1 deletion src/main/java/dansplugins/wildpets/commands/RenameCommand.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package dansplugins.wildpets.commands;

import dansplugins.wildpets.data.EphemeralData;
import dansplugins.wildpets.exceptions.PetRecordNotFoundException;
import dansplugins.wildpets.pet.list.PetListRepository;
import dansplugins.wildpets.pet.Pet;
import dansplugins.wildpets.config.ConfigService;
import dansplugins.wildpets.pet.record.PetRecord;
import dansplugins.wildpets.pet.record.PetRecordRepository;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import preponderous.ponder.minecraft.bukkit.abs.AbstractPluginCommand;

import org.bukkit.ChatColor;
Expand Down Expand Up @@ -73,7 +77,25 @@ public boolean execute(CommandSender sender, String[] args) {
}

pet.setName(newName);
petRecordRepository.getPetRecord(pet.getUniqueID()).setName(newName);
Entity entity = Bukkit.getEntity(pet.getUniqueID());

if (entity != null) {
entity.setCustomName(ChatColor.GREEN + pet.getName());
}
PetRecord petRecord;
try {
petRecord = petRecordRepository.getPetRecord(pet.getUniqueID());
} catch (PetRecordNotFoundException e) {
petRecordRepository.addPetRecord(pet);
try {
petRecord = petRecordRepository.getPetRecord(pet.getUniqueID());
} catch (PetRecordNotFoundException ex) {
ex.printStackTrace();
player.sendMessage(ChatColor.RED + "Pet record wasn't found & the plugin wasn't able to recover. Please report this problem to the community.");
return false;
}
}
petRecord.setName(newName);
player.sendMessage(ChatColor.GREEN + "Renamed.");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ public ArrayList<EntityConfig> getDefaults() {
ArrayList<EntityConfig> configurations = new ArrayList<>();

// passive mobs
configurations.add(new EntityConfig("Allay", 0.5, Material.COOKIE, 8, true));
configurations.add(new EntityConfig("Axolotl", 0.5, Material.KELP, 16, true));
configurations.add(new EntityConfig("Bat", 0.5, Material.PUMPKIN_PIE, 1, true));
configurations.add(new EntityConfig("Camel", 0.5, Material.CACTUS, 8, true));
configurations.add(new EntityConfig("Cat", 0.5, Material.SALMON, 8, true));
configurations.add(new EntityConfig("Chicken", 0.5, Material.WHEAT_SEEDS, 8, true));
configurations.add(new EntityConfig("Cod", 0.5, Material.KELP, 16, true));
configurations.add(new EntityConfig("Cow", 0.5, Material.WHEAT, 32, true));
configurations.add(new EntityConfig("Donkey", 0.5, Material.CARROT, 8, true));
configurations.add(new EntityConfig("Fox", 0.5, Material.SWEET_BERRIES, 8, true));
configurations.add(new EntityConfig("Frog", 0.5, Material.SLIME_BALL, 8, true));
configurations.add(new EntityConfig("Glow_Squid", 0.5, Material.KELP, 24, true));
configurations.add(new EntityConfig("Horse", 0.5, Material.APPLE, 8, true));
configurations.add(new EntityConfig("Mooshroom", 0.5, Material.RED_MUSHROOM, 8, true));
Expand All @@ -67,6 +70,7 @@ public ArrayList<EntityConfig> getDefaults() {
configurations.add(new EntityConfig("Salmon", 0.5, Material.KELP, 24, true));
configurations.add(new EntityConfig("Sheep", 0.5, Material.WHEAT, 8, true));
configurations.add(new EntityConfig("Skeleton_Horse", 0.5, Material.BONE, 8, true));
configurations.add(new EntityConfig("Sniffer", 0.5, Material.GRASS, 32, true));
configurations.add(new EntityConfig("Snow_Golem", 0.5, Material.SNOWBALL, 32, true));
configurations.add(new EntityConfig("Squid", 0.5, Material.KELP, 24, true));
configurations.add(new EntityConfig("Strider", 0.5, Material.NETHER_WART, 32, true));
Expand Down Expand Up @@ -118,6 +122,7 @@ public ArrayList<EntityConfig> getDefaults() {
configurations.add(new EntityConfig("Stray", 0.5, Material.ARROW, 16, true));
configurations.add(new EntityConfig("Vex", 0.5, Material.IRON_SWORD, 16, true));
configurations.add(new EntityConfig("Vindicator", 0.5, Material.EMERALD, 16, true));
configurations.add(new EntityConfig("Warden", 0.5, Material.TOTEM_OF_UNDYING, 1, true));
configurations.add(new EntityConfig("Witch", 0.5, Material.BROWN_MUSHROOM, 16, true));
configurations.add(new EntityConfig("Wither_Skeleton", 0.5, Material.BONE, 16, true));
configurations.add(new EntityConfig("Zoglin", 0.5, Material.ROTTEN_FLESH, 16, true));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dansplugins.wildpets.exceptions;

public class PetRecordNotFoundException extends Exception {
public PetRecordNotFoundException(String message) {
super(message);
}
}
Loading

0 comments on commit fc862f8

Please sign in to comment.