Initial Commit
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
# To contribute improvements to CI/CD templates, please follow the Development guide at:
|
||||
# https://docs.gitlab.com/ee/development/cicd/templates.html
|
||||
# This specific template is located at:
|
||||
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Maven.gitlab-ci.yml
|
||||
|
||||
# Build JAVA applications using Apache Maven (http://maven.apache.org)
|
||||
# For docker image tags see https://hub.docker.com/_/maven/
|
||||
#
|
||||
# For general lifecycle information see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
|
||||
|
||||
# This template will build and test your projects
|
||||
# * Caches downloaded dependencies and plugins between invocation.
|
||||
# * Verify but don't deploy merge requests.
|
||||
# * Deploy built artifacts from master branch only.
|
||||
|
||||
variables:
|
||||
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
|
||||
MAVEN_OPTS: >-
|
||||
-Dhttps.protocols=TLSv1.2
|
||||
-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository
|
||||
-Dorg.slf4j.simpleLogger.showDateTime=true
|
||||
-Djava.awt.headless=true
|
||||
|
||||
# As of Maven 3.3.0 instead of this you MAY define these options in `.mvn/maven.config` so the same config is used
|
||||
# when running from the command line.
|
||||
# As of Maven 3.6.1, the use of `--no-tranfer-progress` (or `-ntp`) suppresses download and upload messages. The use
|
||||
# of the `Slf4jMavenTransferListener` is no longer necessary.
|
||||
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
|
||||
MAVEN_CLI_OPTS: >-
|
||||
--batch-mode
|
||||
--errors
|
||||
--fail-at-end
|
||||
--show-version
|
||||
--no-transfer-progress
|
||||
-DinstallAtEnd=true
|
||||
-DdeployAtEnd=true
|
||||
|
||||
# This template uses the latest Maven 3 release, e.g., 3.8.6, and OpenJDK 8 (LTS)
|
||||
# for verifying and deploying images
|
||||
# Maven 3.8.x REQUIRES HTTPS repositories.
|
||||
# See https://maven.apache.org/docs/3.8.1/release-notes.html#how-to-fix-when-i-get-a-http-repository-blocked for more.
|
||||
image: maven:3-openjdk-20
|
||||
|
||||
# Cache downloaded dependencies and plugins between builds.
|
||||
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
|
||||
# Be aware that `mvn deploy` will install the built jar into this repository. If you notice your cache size
|
||||
# increasing, consider adding `-Dmaven.install.skip=true` to `MAVEN_OPTS` or in `.mvn/maven.config`
|
||||
cache:
|
||||
paths:
|
||||
- .m2/repository
|
||||
|
||||
# For merge requests do not `deploy` but only run `verify`.
|
||||
# See https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
|
||||
.verify:
|
||||
stage: test
|
||||
script:
|
||||
- 'mvn $MAVEN_CLI_OPTS verify'
|
||||
except:
|
||||
variables:
|
||||
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
|
||||
# Verify merge requests using JDK8
|
||||
verify:jdk20:
|
||||
extends:
|
||||
- .verify
|
||||
|
||||
# To deploy packages from CI, create a `ci_settings.xml` file
|
||||
# For deploying packages to GitLab's Maven Repository: See https://docs.gitlab.com/ee/user/packages/maven_repository/index.html#create-maven-packages-with-gitlab-cicd for more details.
|
||||
# Please note: The GitLab Maven Repository is currently only available in GitLab Premium / Ultimate.
|
||||
# For `master` or `main` branch run `mvn deploy` automatically.
|
||||
deploy:jdk20:
|
||||
stage: deploy
|
||||
script:
|
||||
- if [ ! -f ci_settings.xml ]; then
|
||||
echo "CI settings missing\! If deploying to GitLab Maven Repository, please see https://docs.gitlab.com/ee/user/packages/maven_repository/index.html#create-maven-packages-with-gitlab-cicd for instructions.";
|
||||
fi
|
||||
- 'mvn $MAVEN_CLI_OPTS deploy --settings ci_settings.xml'
|
||||
only:
|
||||
variables:
|
||||
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
Generated
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="mlgrush" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+35
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="gitlab-maven" />
|
||||
<option name="name" value="gitlab-maven" />
|
||||
<option name="url" value="https://Gitlab.Softwarerat.com/api/v4/projects/16/packages/maven" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="sonatype" />
|
||||
<option name="name" value="sonatype" />
|
||||
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="papermc-repo" />
|
||||
<option name="name" value="papermc-repo" />
|
||||
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="22" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/mlgrush.iml" filepath="$PROJECT_DIR$/mlgrush.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,93 @@
|
||||
# mlgrush
|
||||
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
|
||||
## Add your files
|
||||
|
||||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://Gitlab.Softwarerat.com/network/mlgrush.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
|
||||
- [ ] [Set up project integrations](https://Gitlab.Softwarerat.com/network/mlgrush/-/settings/integrations)
|
||||
|
||||
## Collaborate with your team
|
||||
|
||||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||
|
||||
## Test and Deploy
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
|
||||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||
|
||||
***
|
||||
|
||||
# Editing this README
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
|
||||
## Suggestions for a good README
|
||||
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||
@@ -0,0 +1,15 @@
|
||||
<settings>
|
||||
<servers>
|
||||
<server>
|
||||
<id>gitlab-maven</id>
|
||||
<configuration>
|
||||
<httpHeaders>
|
||||
<property>
|
||||
<name>Job-Token</name>
|
||||
<value>${CI_JOB_TOKEN}</value>
|
||||
</property>
|
||||
</httpHeaders>
|
||||
</configuration>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>ADVENTURE</platformType>
|
||||
</autoDetectTypes>
|
||||
<projectReimportVersion>1</projectReimportVersion>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.softwarerat</groupId>
|
||||
<artifactId>mlgrush</artifactId>
|
||||
<version>1.0.24-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>mlgrush</name>
|
||||
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>gitlab-maven</id>
|
||||
<url>https://gitlab.softwarerat.com/api/v4/projects/25/packages/maven</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>gitlab-maven</id>
|
||||
<url>https://gitlab.softwarerat.com/api/v4/projects/25/packages/maven</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
|
||||
<properties>
|
||||
<java.version>18</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<id>papermc-repo</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>gitlab-maven</id>
|
||||
<url>https://Gitlab.Softwarerat.com/api/v4/projects/16/packages/maven</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.21.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.28</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.softwarerat</groupId>
|
||||
<artifactId>GameAPI</artifactId>
|
||||
<version>1.6.4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,15 @@
|
||||
<settings>
|
||||
<servers>
|
||||
<server>
|
||||
<id>gitlab-maven</id>
|
||||
<configuration>
|
||||
<httpHeaders>
|
||||
<property>
|
||||
<name>Job-Token</name>
|
||||
<value>${CI_JOB_TOKEN}</value>
|
||||
</property>
|
||||
</httpHeaders>
|
||||
</configuration>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
@@ -0,0 +1,67 @@
|
||||
package de.softwarerat.MLGRush.GameState;
|
||||
|
||||
|
||||
import com.softwarerat.API.builder.SpigotInventory;
|
||||
import com.softwarerat.API.builder.SpigotItem;
|
||||
import com.softwarerat.API.gameState.IGameState;
|
||||
import de.softwarerat.MLGRush.MLGRush;
|
||||
import de.softwarerat.MLGRush.data.Scores;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class IngameState implements IGameState {
|
||||
|
||||
public IngameState(Scores scores) {
|
||||
this.scores = scores;
|
||||
}
|
||||
|
||||
Scores scores;
|
||||
Location location;
|
||||
Location location2;
|
||||
@Getter
|
||||
Player player1;
|
||||
@Getter
|
||||
Player player2;
|
||||
@Override
|
||||
public void Start() {
|
||||
location = new Location(Bukkit.getWorld("ingame"),19,53,0);
|
||||
location2 = new Location(Bukkit.getWorld("ingame"),-19,53,0);
|
||||
AtomicReference<Boolean> teleported = new AtomicReference<>(false);
|
||||
Bukkit.getOnlinePlayers().forEach(player ->
|
||||
{
|
||||
SpigotInventory spigotInventory = new SpigotInventory(player, MLGRush.getPlugin(MLGRush.class));
|
||||
spigotInventory.addItem(new SpigotItem(Material.SANDSTONE,64).build());
|
||||
spigotInventory.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build());
|
||||
spigotInventory.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build());
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
scores.getScoreBlue().set(0);
|
||||
scores.getScoreRed().set(0);
|
||||
if (!teleported.get()){
|
||||
teleported.set(true);
|
||||
player1 = player;
|
||||
player1.teleport(location);
|
||||
player1.setRespawnLocation(location);
|
||||
} else {
|
||||
player2 = player;
|
||||
player2.teleport(location2);
|
||||
player2.setRespawnLocation(location2);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Stop() {
|
||||
Bukkit.getServer().shutdown();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.softwarerat.MLGRush.GameState;
|
||||
|
||||
import com.softwarerat.API.gameState.IGameState;
|
||||
import com.softwarerat.API.world.WorldAPI;
|
||||
|
||||
public class LobbyState implements IGameState {
|
||||
IngameState ingameState;
|
||||
WorldAPI worldAPI;
|
||||
|
||||
public LobbyState(IngameState ingameState, WorldAPI worldAPI) {
|
||||
this.ingameState = ingameState;
|
||||
this.worldAPI = worldAPI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Start() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Stop() {
|
||||
worldAPI.loadWorld("ingame");
|
||||
ingameState.Start();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package de.softwarerat.MLGRush;
|
||||
|
||||
import com.softwarerat.API.prefix.PrefixAPI;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class IPrefix {
|
||||
PrefixAPI prefixAPI;
|
||||
|
||||
public IPrefix(PrefixAPI prefixAPI) {
|
||||
this.prefixAPI = prefixAPI;
|
||||
}
|
||||
|
||||
public void permissiblePrefix(Player player) {
|
||||
if (player.hasPermission("prefix.Admin")) {
|
||||
this.prefixAPI.addPlayerToTeam("Admin", 1, player);
|
||||
} else if (player.hasPermission("prefix.Moderator")) {
|
||||
this.prefixAPI.addPlayerToTeam("Mod", 2, player);
|
||||
} else if (player.hasPermission("prefix.Content")) {
|
||||
this.prefixAPI.addPlayerToTeam("Content", 3, player);
|
||||
} else if (player.hasPermission("prefix.Creator")) {
|
||||
this.prefixAPI.addPlayerToTeam("Creator", 4, player);
|
||||
} else {
|
||||
this.prefixAPI.addPlayerToTeam("Player", 5, player);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayerFromTeam(Player player) {
|
||||
if (player.hasPermission("prefix.Admin")) {
|
||||
this.prefixAPI.removePlayerFromTeam("Admin", 1, player);
|
||||
} else if (player.hasPermission("prefix.Moderator")) {
|
||||
this.prefixAPI.removePlayerFromTeam("Mod", 2, player);
|
||||
} else if (player.hasPermission("prefix.Content")) {
|
||||
this.prefixAPI.removePlayerFromTeam("Content", 3, player);
|
||||
} else if (player.hasPermission("prefix.Creator")) {
|
||||
this.prefixAPI.removePlayerFromTeam("Creator", 4, player);
|
||||
} else {
|
||||
this.prefixAPI.removePlayerFromTeam("Player", 5, player);
|
||||
}
|
||||
}
|
||||
|
||||
public String getRank(Player player) {
|
||||
if (player.hasPermission("prefix.Admin"))
|
||||
return String.valueOf(ChatColor.RED) + "Administrator";
|
||||
if (player.hasPermission("prefix.Moderator"))
|
||||
return String.valueOf(ChatColor.YELLOW) + "Moderator";
|
||||
if (player.hasPermission("prefix.Content"))
|
||||
return String.valueOf(ChatColor.GOLD) + "Content";
|
||||
if (player.hasPermission("prefix.Creator"))
|
||||
return String.valueOf(ChatColor.DARK_PURPLE) + "Creator";
|
||||
return String.valueOf(ChatColor.GRAY) + "Spieler";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package de.softwarerat.MLGRush;
|
||||
|
||||
import com.softwarerat.API.data.GameData;
|
||||
import com.softwarerat.API.prefix.PrefixAPI;
|
||||
import com.softwarerat.API.world.WorldAPI;
|
||||
import com.softwarerat.GameAPI;
|
||||
import de.softwarerat.MLGRush.GameState.IngameState;
|
||||
import de.softwarerat.MLGRush.GameState.LobbyState;
|
||||
import de.softwarerat.MLGRush.data.Scores;
|
||||
import de.softwarerat.MLGRush.listener.BlockBreakListener;
|
||||
import de.softwarerat.MLGRush.listener.JoinListener;
|
||||
import de.softwarerat.MLGRush.listener.OutOfAreaListener;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
public final class MLGRush extends JavaPlugin {
|
||||
GameAPI gameAPI;
|
||||
GameData gameData;
|
||||
@Getter
|
||||
PrefixAPI prefixAPI;
|
||||
IPrefix iPrefix;
|
||||
Scores scores;
|
||||
LobbyState lobbyState;
|
||||
IngameState ingameState;
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
// Plugin startup logic
|
||||
gameAPI = new GameAPI();
|
||||
gameAPI.enableAPI(this);
|
||||
gameAPI.setJavaPlugin(this);
|
||||
gameAPI.getLocationAPI();
|
||||
gameAPI.getWorldAPI();
|
||||
gameData = new GameData(gameAPI);
|
||||
gameAPI.setGameData(gameData);
|
||||
Scoreboard scoreboard;
|
||||
scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
gameData.setScoreboard(scoreboard);
|
||||
prefixAPI = new PrefixAPI(scoreboard);
|
||||
|
||||
if (Bukkit.getScoreboardManager().getMainScoreboard().getTeam("1Admin") == null){
|
||||
prefixAPI.createPrefix("Admin", 01, ChatColor.RED + "Admin " + ChatColor.GRAY + "| ");
|
||||
Bukkit.getScoreboardManager().getMainScoreboard().getTeam("1Admin").setColor(ChatColor.GRAY);
|
||||
} else if (Bukkit.getScoreboardManager().getMainScoreboard().getTeam("2Mod") == null){
|
||||
prefixAPI.createPrefix("Mod", 02, ChatColor.YELLOW + "Mod " + ChatColor.GRAY + "| ");
|
||||
Bukkit.getScoreboardManager().getMainScoreboard().getTeam("2Mod").setColor(ChatColor.GRAY);
|
||||
}else if (Bukkit.getScoreboardManager().getMainScoreboard().getTeam("3Content") == null){
|
||||
prefixAPI.createPrefix("Content", 03, ChatColor.GOLD + "Content " + ChatColor.GRAY + "| ");
|
||||
Bukkit.getScoreboardManager().getMainScoreboard().getTeam("3Content").setColor(ChatColor.GRAY);
|
||||
}else if (Bukkit.getScoreboardManager().getMainScoreboard().getTeam("4Creator") == null){
|
||||
prefixAPI.createPrefix("Creator", 04, ChatColor.DARK_PURPLE + " Creator " + ChatColor.GRAY + "| ");
|
||||
Bukkit.getScoreboardManager().getMainScoreboard().getTeam("4Creator").setColor(ChatColor.GRAY);
|
||||
}else if (Bukkit.getScoreboardManager().getMainScoreboard().getTeam("5Player") == null){
|
||||
prefixAPI.createPrefix("Player", 05, "Spieler " + ChatColor.GRAY + "| ");
|
||||
Bukkit.getScoreboardManager().getMainScoreboard().getTeam("5Player").setColor(ChatColor.GRAY);
|
||||
}
|
||||
if (Bukkit.getWorld("world") != null) {
|
||||
World w = Bukkit.getWorld("world");
|
||||
Location location = new Location(w, -23.0D, 69.0D, 22.0D);
|
||||
}
|
||||
if (gameAPI == null) {
|
||||
System.out.println("Error");
|
||||
}
|
||||
// Plugin startup logic
|
||||
iPrefix = new IPrefix(prefixAPI);
|
||||
scores = new Scores();
|
||||
ingameState = new IngameState(scores);
|
||||
lobbyState = new LobbyState(ingameState,new WorldAPI());
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new JoinListener(lobbyState,iPrefix),this);
|
||||
Bukkit.getPluginManager().registerEvents(new BlockBreakListener(scores, ingameState),this);
|
||||
Bukkit.getPluginManager().registerEvents(new OutOfAreaListener(ingameState),this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package de.softwarerat.MLGRush.data;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class Scores {
|
||||
AtomicInteger ScoreRed = new AtomicInteger(0);
|
||||
AtomicInteger ScoreBlue = new AtomicInteger(0);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package de.softwarerat.MLGRush.listener;
|
||||
|
||||
import com.softwarerat.API.builder.SpigotInventory;
|
||||
import com.softwarerat.API.builder.SpigotItem;
|
||||
import de.softwarerat.MLGRush.GameState.IngameState;
|
||||
import de.softwarerat.MLGRush.MLGRush;
|
||||
import de.softwarerat.MLGRush.data.Scores;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class BlockBreakListener implements Listener {
|
||||
Scores scores;
|
||||
IngameState ingameState;
|
||||
Player player1;
|
||||
Player player2;
|
||||
|
||||
public BlockBreakListener(Scores scores, IngameState ingameState) {
|
||||
this.scores = scores;
|
||||
this.ingameState = ingameState;
|
||||
|
||||
}
|
||||
Location location;
|
||||
Location location2;
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
player2 = ingameState.getPlayer2();
|
||||
player1 = ingameState.getPlayer1();
|
||||
if (!(event.getBlock().getBlockData().getMaterial() == Material.SANDSTONE)) {
|
||||
event.setCancelled(true);
|
||||
if (event.getBlock().getBlockData().getMaterial() == Material.BLUE_BED) {
|
||||
if (event.getPlayer().equals(player1)){
|
||||
scores.getScoreRed().getAndIncrement();
|
||||
location = new Location(Bukkit.getWorld("ingame"),19,53,0);
|
||||
location2 = new Location(Bukkit.getWorld("ingame"),-19,53,0);
|
||||
AtomicReference<Boolean> teleported = new AtomicReference<>(false);
|
||||
SpigotInventory spigotInventory = new SpigotInventory(player1, MLGRush.getPlugin(MLGRush.class));
|
||||
spigotInventory.clear();
|
||||
spigotInventory.addItem(new SpigotItem(Material.SANDSTONE,64).build());
|
||||
spigotInventory.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build());
|
||||
spigotInventory.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build());
|
||||
SpigotInventory spigotInventory1 = new SpigotInventory(player2, MLGRush.getPlugin(MLGRush.class));
|
||||
spigotInventory1.clear();
|
||||
spigotInventory1.addItem(new SpigotItem(Material.SANDSTONE,64).build());
|
||||
spigotInventory1.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build());
|
||||
spigotInventory1.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build());
|
||||
player1.teleport(location);
|
||||
player2.teleport(location2);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage("Rot +1"));
|
||||
}
|
||||
|
||||
} else if (event.getBlock().getBlockData().getMaterial() == Material.RED_BED) {
|
||||
if (event.getPlayer().equals(player2)) {
|
||||
SpigotInventory spigotInventory = new SpigotInventory(player1, MLGRush.getPlugin(MLGRush.class));
|
||||
spigotInventory.clear();
|
||||
spigotInventory.addItem(new SpigotItem(Material.SANDSTONE,64).build());
|
||||
spigotInventory.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build());
|
||||
spigotInventory.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build());
|
||||
SpigotInventory spigotInventory1 = new SpigotInventory(player2, MLGRush.getPlugin(MLGRush.class));
|
||||
spigotInventory1.clear();
|
||||
spigotInventory1.addItem(new SpigotItem(Material.SANDSTONE,64).build());
|
||||
spigotInventory1.addItem(new SpigotItem(Material.STICK,1).addUnsafeEnchantment(Enchantment.KNOCKBACK,1).build());
|
||||
spigotInventory1.addItem(new SpigotItem(Material.WOODEN_PICKAXE,1).addEnchant(Enchantment.EFFICIENCY,5).setUnbreakable(true).build());
|
||||
location = new Location(Bukkit.getWorld("ingame"), 19, 53, 0);
|
||||
location2 = new Location(Bukkit.getWorld("ingame"), -19, 53, 0);
|
||||
scores.getScoreBlue().getAndIncrement();
|
||||
player1.teleport(location);
|
||||
player2.teleport(location2);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage("Blau +1"));
|
||||
}
|
||||
}
|
||||
|
||||
if (scores.getScoreRed().get() == 10) {
|
||||
ingameState.Stop();
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
player.sendTitle("Rot hat gewonnen", "server startet nun neu");
|
||||
});
|
||||
} else if (scores.getScoreBlue().get() == 10) {
|
||||
ingameState.Stop();
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
player.sendTitle("Blau hat gewonnen", "server startet nun neu");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package de.softwarerat.MLGRush.listener;
|
||||
|
||||
|
||||
import de.softwarerat.MLGRush.GameState.LobbyState;
|
||||
import de.softwarerat.MLGRush.IPrefix;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
|
||||
public class JoinListener implements Listener {
|
||||
LobbyState lobbyState;
|
||||
IPrefix iPrefix;
|
||||
|
||||
public JoinListener(LobbyState lobbyState, IPrefix iPrefix) {
|
||||
this.lobbyState = lobbyState;
|
||||
this.iPrefix = iPrefix;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
public void onEvent(PlayerJoinEvent event) {
|
||||
System.out.println("new join");
|
||||
Location location = new Location(Bukkit.getWorld("world"), 0.0D, 68.0D, -8.0D);
|
||||
Player player = event.getPlayer();
|
||||
player.teleport(location);
|
||||
this.iPrefix.permissiblePrefix(player);
|
||||
event.setJoinMessage("");
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
System.out.println("playerjoin:"+ event.getPlayer().getName());
|
||||
player.setPlayerListHeader(ChatColor.DARK_PURPLE.toString() + ChatColor.BOLD + "\n Fourty6Media \n");
|
||||
Bukkit.getOnlinePlayers().forEach(players -> {
|
||||
players.setPlayerListFooter(ChatColor.DARK_AQUA.toString() + ChatColor.BOLD + "\n Online: "+ (long) Bukkit.getOnlinePlayers().size() +" \n");
|
||||
});
|
||||
|
||||
if ( Bukkit.getOnlinePlayers().size() == 2) {
|
||||
lobbyState.Stop();
|
||||
}
|
||||
|
||||
// new Navigator(click.getPlayer())
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package de.softwarerat.MLGRush.listener;
|
||||
|
||||
import de.softwarerat.MLGRush.GameState.IngameState;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class OutOfAreaListener implements Listener {
|
||||
IngameState ingameState;
|
||||
Player player2;
|
||||
Player player1;
|
||||
Location location;
|
||||
Location location2;
|
||||
|
||||
public OutOfAreaListener(IngameState ingameState) {
|
||||
this.ingameState = ingameState;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
location = new Location(Bukkit.getWorld("ingame"),19,53,0);
|
||||
location2 = new Location(Bukkit.getWorld("ingame"),-19,53,0);
|
||||
player2 = ingameState.getPlayer2();
|
||||
player1 = ingameState.getPlayer1();
|
||||
if (event.getPlayer().getLocation().getBlockY() <= 39){
|
||||
if (event.getPlayer().getName().equals(player1.getName())){
|
||||
player1.teleport(location);
|
||||
|
||||
}else {
|
||||
player2.teleport(location2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
name: MLGRush
|
||||
version: '1.0-SNAPSHOT'
|
||||
main: de.softwarerat.MLGRush.MLGRush
|
||||
api-version: '1.21'
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
name: MLGRush
|
||||
version: '1.0-SNAPSHOT'
|
||||
main: de.softwarerat.MLGRush.MLGRush
|
||||
api-version: '1.21'
|
||||
@@ -0,0 +1,8 @@
|
||||
/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/GameState/IngameState.java
|
||||
/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/GameState/LobbyState.java
|
||||
/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/IPrefix.java
|
||||
/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/MLGRush.java
|
||||
/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/data/Scores.java
|
||||
/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/listener/BlockBreakListener.java
|
||||
/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/listener/JoinListener.java
|
||||
/Users/zlavra/code/MLGRush/src/main/java/de/softwarerat/MLGRush/listener/OutOfAreaListener.java
|
||||
Reference in New Issue
Block a user