This commit is contained in:
TheTechRobo 2022-03-17 21:40:54 -04:00
commit a9d21d4882
9 changed files with 171 additions and 0 deletions

39
.classpath Normal file
View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
build/
target/

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>steakonfirstjoin</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17

View File

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

4
plugin.yml Normal file
View File

@ -0,0 +1,4 @@
name: GivePlayerSteak
main: ca.thetechrobo.steakonfirstjoin.SteakOnFirstJoin
version: 1.0
api-version: 1.18

25
pom.xml Normal file
View File

@ -0,0 +1,25 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ca.thetechrobo.steakonfirstjoin</groupId>
<artifactId>steakonfirstjoin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Steak on first join</name>
<description>Does what it says on the tin., Gives a player half a stack of steak if they haven't gotten it already.</description>
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>purpur-repo</id>
<url>https://repo.purpurmc.org/snapshots</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Purpur API artifact to the build -->
<dependency>
<groupId>org.purpurmc.purpur</groupId>
<artifactId>purpur-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,50 @@
package ca.thetechrobo.steakonfirstjoin;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
public class GiveSteakToPlayer implements Listener {
private SteakOnFirstJoin pl;
public boolean canPlayerGetSteak(Player p) {
PersistentDataContainer cont = p.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(this.pl, "canHasSteak");
if (cont.has(key))
return false;
else
return true;
}
public void playerGotSteak(Player p) {
PersistentDataContainer cont = p.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(this.pl, "canHasSteak");
cont.set(key, PersistentDataType.BYTE, (byte) 69);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if (!(canPlayerGetSteak(p))) {
return;
}
ItemStack steak = new ItemStack(Material.COOKED_BEEF);
steak.setAmount(32);
playerGotSteak(p);
p.getInventory().addItem(steak);
p.sendMessage(Component.text("As this is your first time playing, you receive 32 Steak.")
.color(TextColor.color(0, 100, 155)));
Bukkit.broadcast(Component.text(p.getName() + " joined the server for the first time!")
.color(TextColor.color(0, 255, 0)));
}
public GiveSteakToPlayer(SteakOnFirstJoin plugin) {
this.pl = plugin;
}
}

View File

@ -0,0 +1,13 @@
package ca.thetechrobo.steakonfirstjoin;
import org.bukkit.plugin.java.JavaPlugin;
public class SteakOnFirstJoin extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new GiveSteakToPlayer(this), this);
}
@Override
public void onDisable() {
}
}