initial commit

This commit is contained in:
Laura
2026-01-18 15:09:04 +01:00
commit 1d18d3dd7e
15 changed files with 800 additions and 0 deletions
+113
View File
@@ -0,0 +1,113 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# Common working directory
run/
+80
View File
@@ -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
+93
View File
@@ -0,0 +1,93 @@
# lobby
## 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/lobby.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://Gitlab.Softwarerat.com/network/lobby/-/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.
+15
View File
@@ -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>
+97
View File
@@ -0,0 +1,97 @@
<?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>Lobby</artifactId>
<version>1.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Lobby</name>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>https://Gitlab.Softwarerat.com/api/v4/projects/16/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>https://Gitlab.Softwarerat.com/api/v4/projects/16/packages/maven</url>
</snapshotRepository>
</distributionManagement>
<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>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>gitlab-maven</id>
<url>https://Gitlab.Softwarerat.com/api/v4/projects/16/packages/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.softwarerat</groupId>
<artifactId>GameAPI</artifactId>
<version>1.6.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>24.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
+15
View File
@@ -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,53 @@
package de.softwarerat.lobby;
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 ChatColor.RED + "Administrator";
if (player.hasPermission("prefix.Moderator"))
return ChatColor.YELLOW + "Moderator";
if (player.hasPermission("prefix.Content"))
return ChatColor.GOLD + "Content";
if (player.hasPermission("prefix.Creator"))
return ChatColor.DARK_PURPLE + "Creator";
return ChatColor.GRAY + "Spieler";
}
}
@@ -0,0 +1,87 @@
package de.softwarerat.lobby;
import com.softwarerat.API.data.GameData;
import com.softwarerat.API.listener.BuildBreakListener;
import com.softwarerat.API.listener.LobbyInventoryClickListener;
import com.softwarerat.API.prefix.PrefixAPI;
import com.softwarerat.GameAPI;
import de.softwarerat.lobby.commands.FlyCommand;
import de.softwarerat.lobby.listener.JoinListener;
import de.softwarerat.lobby.listener.QuitListener;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.bukkit.scoreboard.Scoreboard;
import org.jetbrains.annotations.NotNull;
public final class Lobby extends JavaPlugin implements PluginMessageListener {
GameAPI gameAPI;
@Getter
PrefixAPI prefixAPI;
@Override
public void onEnable() {
PluginManager pluginManager = Bukkit.getPluginManager();
// Plugin startup logic
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", this);
gameAPI = new GameAPI();
gameAPI.enableAPI(this);
GameData gameData;
gameData = new GameData(gameAPI);
gameAPI.setGameData(gameData);
Scoreboard scoreboard;
scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
gameData.setScoreboard(scoreboard);
prefixAPI = new PrefixAPI(scoreboard);
IPrefix iPrefix = new IPrefix(prefixAPI);
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 (gameAPI == null) {
System.out.println("Error");
}
pluginManager.registerEvents(new JoinListener(iPrefix), this);
pluginManager.registerEvents(new QuitListener(iPrefix), this);
pluginManager.registerEvents(new BuildBreakListener(), this);
pluginManager.registerEvents(new LobbyInventoryClickListener(), this);
getCommand("fly").setExecutor(new FlyCommand());
if (Bukkit.getWorld("world") != null) {
World w = Bukkit.getWorld("world");
Location location = new Location(w, -23.0D, 69.0D, 22.0D);
}
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
@Override
public void onPluginMessageReceived(@NotNull String s, @NotNull Player player, @NotNull byte[] bytes) {
}
}
@@ -0,0 +1,26 @@
package de.softwarerat.lobby.MenuAPI;
import com.softwarerat.API.builder.ItemBuilder;
import lombok.Getter;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class Navigator extends PageBuilder {
@Getter
ItemStack icon = PageIcon;
public Navigator(Player player) {
super("Server auswählen", new ItemBuilder(Material.GRAY_STAINED_GLASS_PANE).setDisplayname(" ").build(), player);
}
@Override
public void create(Player createdOn) {
PageIcon = new ItemBuilder(Material.STONE).setDisplayname(" ").build();
player.openInventory(page);
System.out.println("test");
}
}
@@ -0,0 +1,101 @@
package de.softwarerat.lobby.MenuAPI;
import de.softwarerat.lobby.Lobby;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
public abstract class PageBuilder implements Listener {
private static final Map<Player, Boolean> openList = new HashMap<>();
private final Map<Integer, Consumer<InventoryClickEvent>> clickActions;
protected ItemStack PageIcon;
protected ItemStack[] items;
protected ArrayList<Integer> borderInt;
protected Inventory page;
protected Player player;
public PageBuilder(String pageName, ItemStack borderItem, Player player) {
this.borderInt = new ArrayList<>();
this.player = player;
addBorderInt();
openList.put(player, false);
page = Bukkit.createInventory(player, 27, pageName);
borderInt.forEach(integer -> page.setItem(integer, borderItem));
this.clickActions = new HashMap<>();
Bukkit.getPluginManager().registerEvents(this, Lobby.getPlugin(Lobby.class));
create(player);
}
public abstract void create(Player createdOn);
private void addBorderInt() {
borderInt.add(1);
borderInt.add(2);
borderInt.add(3);
borderInt.add(4);
borderInt.add(5);
borderInt.add(6);
borderInt.add(7);
borderInt.add(8);
borderInt.add(0);
borderInt.add(9);
borderInt.add(17);
borderInt.add(19);
borderInt.add(18);
borderInt.add(20);
borderInt.add(21);
borderInt.add(22);
borderInt.add(23);
borderInt.add(24);
borderInt.add(25);
borderInt.add(26);
}
@EventHandler
public void executeActions(InventoryClickEvent clickEvent) {
Inventory clickedInventory = clickEvent.getClickedInventory();
if (clickedInventory == null) {
}
}
public void addItem(ItemStack item, int slot, Consumer<InventoryClickEvent> clickAction) {
this.page.setItem(slot, item);
this.clickActions.put(slot, clickAction);
}
public void addItem(ItemStack item, int slot) {
this.page.setItem(slot, item);
}
@EventHandler
public void openInventory(InventoryOpenEvent openEvent) {
Inventory openInventory = openEvent.getInventory();
if (openInventory.getType() != InventoryType.CHEST) return;
openList.put(player, true);
}
@EventHandler
public void closeInventory(InventoryCloseEvent closeEvent) {
Inventory closeInventory = closeEvent.getInventory();
if (Boolean.FALSE.equals(openList.get(closeEvent.getPlayer()))) return;
if (closeInventory.getType() != InventoryType.CHEST) return;
openList.put(player, false);
}
}
@@ -0,0 +1,6 @@
package de.softwarerat.lobby.MenuAPI;
public class TestMenu {
}
@@ -0,0 +1,27 @@
package de.softwarerat.lobby.commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class FlyCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
Player player = Bukkit.getPlayer(commandSender.getName());
assert player != null;
boolean flying = player.isFlying();
if (!flying) {
player.setAllowFlight(true);
player.setFlying(true);
player.sendMessage(ChatColor.RED + "Server " + ChatColor.GRAY + "| Du kannst nun fliegen!");
} else {
player.setAllowFlight(false);
player.setFlying(false);
player.sendMessage(ChatColor.RED + "Server " + ChatColor.GRAY + "| Du kannst nun nicht mehr fliegen!");
}
return false;
}
}
@@ -0,0 +1,56 @@
package de.softwarerat.lobby.listener;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.softwarerat.API.builder.SpigotInventory;
import com.softwarerat.API.builder.SpigotItem;
import de.softwarerat.lobby.IPrefix;
import de.softwarerat.lobby.Lobby;
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 {
IPrefix iPrefix;
public JoinListener(IPrefix iPrefix) {
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");
});
event.getPlayer().getInventory().clear();
SpigotInventory playerInventory = new SpigotInventory(player, Lobby.getPlugin(Lobby.class));
if (player.hasPermission("lobby.build"))
playerInventory.setSlot(new SpigotItem(Material.GRASS_BLOCK).setName(ChatColor.BLUE.toString() + ChatColor.BOLD + "Bauserver Joinen " + ChatColor.RESET + ChatColor.GRAY + "(Click)").build(), 4, (click) -> {
sendPlayer(player, "build-1");
});
}
public void sendPlayer(Player player, String targetServer) {
if (player.hasPermission("network.useServerNavigator")) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(targetServer);
player.sendPluginMessage(Lobby.getPlugin(Lobby.class), "BungeeCord", out.toByteArray());
}
}
}
@@ -0,0 +1,22 @@
package de.softwarerat.lobby.listener;
import de.softwarerat.lobby.IPrefix;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class QuitListener implements Listener {
IPrefix iPrefix;
public QuitListener(IPrefix iPrefix) {
this.iPrefix = iPrefix;
}
@EventHandler
public void onEvent(PlayerQuitEvent event) {
System.out.println("new Quit");
event.setQuitMessage("");
this.iPrefix.removePlayerFromTeam(event.getPlayer());
}
}
+9
View File
@@ -0,0 +1,9 @@
name: Lobby
version: '1.0-SNAPSHOT'
main: de.softwarerat.lobby.Lobby
api-version: '1.20'
commands:
fly:
permission: lobby.fly
navigator:
permission: lobby.navigator