first commit
This commit is contained in:
BIN
._.DS_Store
Executable file
BIN
._.DS_Store
Executable file
Binary file not shown.
BIN
._README.md
Executable file
BIN
._README.md
Executable file
Binary file not shown.
BIN
._environmentex
Executable file
BIN
._environmentex
Executable file
Binary file not shown.
5
.vscode/settings.json
vendored
Executable file
5
.vscode/settings.json
vendored
Executable file
@@ -0,0 +1,5 @@
|
||||
{"files.autoGuessEncoding": true,
|
||||
"files.encoding": "utf8",
|
||||
"java.jdt.ls.vmargs": "-Dfile.encoding=UTF-8",
|
||||
"java.configuration.updateBuildConfiguration": "automatic"
|
||||
}
|
||||
36
.vscode/tasks.json
vendored
Executable file
36
.vscode/tasks.json
vendored
Executable file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
/*{
|
||||
"type": "java",
|
||||
"targetPath": "${workspaceFolder}/${workspaceFolderBasename}.jar",
|
||||
"elements": [
|
||||
"${compileOutput:betterhoppers}",
|
||||
"${dependencies:betterhoppers}",
|
||||
"${compileOutput:chestex}",
|
||||
"${dependencies:chestex}",
|
||||
"${compileOutput:dailyquests}",
|
||||
"${dependencies:dailyquests}",
|
||||
"${compileOutput:environmentex}",
|
||||
"${dependencies:environmentex}",
|
||||
"${compileOutput:pokeballs}",
|
||||
"${dependencies:pokeballs}"
|
||||
],
|
||||
"problemMatcher": [],
|
||||
"label": "java: exportjar:MCPlugins",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},*/
|
||||
{
|
||||
"label": "EnvironmentEx",
|
||||
"type": "shell",
|
||||
"command": "/usr/bin/mvn clean -f '/mnt/fileserver/DOKUMENTE/Programmierung/MCServer/MCPlugins/environmentex/pom.xml' && /usr/bin/mvn install -f '/mnt/fileserver/DOKUMENTE/Programmierung/MCServer/MCPlugins/environmentex/pom.xml'",
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
30
README.md
Executable file
30
README.md
Executable file
@@ -0,0 +1,30 @@
|
||||
|
||||
git init
|
||||
git checkout -b main
|
||||
git add README.md
|
||||
git commit -m "first commit"
|
||||
git remote add origin https://gitea.hessj.de/administrator/MCPlugins.git
|
||||
git push -u origin main
|
||||
|
||||
|
||||
INFO: CustomItemIcon count: 22
|
||||
|
||||
IDEA: schere verschiedene versionen pferde/mule/cats/schafe/Axolotl/tropical etc?
|
||||
|
||||
|
||||
FIX: Infinity Bucket
|
||||
ADD: TOTEM BACKPACK LOOKUP
|
||||
|
||||
|
||||
cauldron concrete to web
|
||||
shulker preview SHIFT + Rechtsklick
|
||||
infinite water
|
||||
Armored Elytra
|
||||
TO RELEASE: waterbottle + sponge = empty bottle
|
||||
TO RELEASE: AFK Funktion
|
||||
TO RELEASE: Autocrafter
|
||||
VON WEBSITE NEHMEN: BÜCHERREGAL
|
||||
TO RELEASE: Infinity Bucket (wers glaubt)
|
||||
TO RELEASE: TOTEM
|
||||
|
||||
ALLGEMEIN: recipes die custom items beinhalten werden nicht im crafting angezeigt (allgm. Bukkit problem)
|
||||
73
betterhoppers/pom.xml
Executable file
73
betterhoppers/pom.xml
Executable file
@@ -0,0 +1,73 @@
|
||||
<?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.hessj.betterhoppers</groupId>
|
||||
<artifactId>betterhoppers</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.20-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>mc-api</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/CraftBukkit.jar</systemPath>
|
||||
<!--systemPath>\\fileserver\Janik\DOKUMENTE\Programmierung\MCServer\MCPlugins\CraftBukkit.jar</systemPath>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hessj.helper</groupId>
|
||||
<artifactId>helper</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<!--<systemPath>\\fileserver\Janik\DOKUMENTE\Programmierung\MCServer\MCPlugins\helper\target\helper-1.0-SNAPSHOT.jar</systemPath>-->
|
||||
<systemPath>/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/helper/target/helper-1.0-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>config.yml</include>
|
||||
<include>players.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<outputDirectory>/mnt/minecrafttest/plugins</outputDirectory>
|
||||
<!--<outputDirectory>\\fileserver\MinecraftTEST\plugins</outputDirectory>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
107
betterhoppers/src/main/java/de/hessj/betterhoppers/App.java
Executable file
107
betterhoppers/src/main/java/de/hessj/betterhoppers/App.java
Executable file
@@ -0,0 +1,107 @@
|
||||
package de.hessj.betterhoppers;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
import org.bukkit.util.io.BukkitObjectOutputStream;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class App extends JavaPlugin {
|
||||
public static App main;
|
||||
public de.hessj.helper.Helper helper= new de.hessj.helper.Helper();
|
||||
public PluginManager pM = Bukkit.getPluginManager();
|
||||
NamespacedKey nskHopper = new NamespacedKey(this, "R3SFILTERHOPPER");
|
||||
String name = "Trichterfilter";
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
main = this;
|
||||
getLogger().info("Plugin enabled!");
|
||||
listenerRegistration();
|
||||
|
||||
ItemStack hopper = new ItemStack(Material.HOPPER);
|
||||
ItemMeta im = hopper.getItemMeta();
|
||||
im.displayName(Component.text(ChatColor.WHITE + name));
|
||||
im.lore(Arrays.asList(Component.text(ChatColor.GRAY + "STRG + Rechtsklick auf den platzierten Filter"),
|
||||
Component.text(ChatColor.GRAY + "ohne Item in der Hand, um den Filter zu öffnen")));
|
||||
im.setCustomModelData(1000021);
|
||||
hopper.setItemMeta(im);
|
||||
|
||||
ShapelessRecipe srHopper = new ShapelessRecipe(nskHopper, hopper);
|
||||
srHopper.addIngredient(Material.HOPPER);
|
||||
srHopper.addIngredient(Material.COMPARATOR);
|
||||
getServer().addRecipe(srHopper);
|
||||
if (getServer().getRecipe(nskHopper) == null) {
|
||||
getServer().addRecipe(srHopper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Plugin disabled!");
|
||||
}
|
||||
|
||||
private void listenerRegistration() {
|
||||
pM.registerEvents(new BetterHopperListener(), this);
|
||||
pM.registerEvents(new LoginListener(), this);
|
||||
}
|
||||
|
||||
public Boolean checkFilterHopper(ItemStack is) {
|
||||
|
||||
if (is.displayName().toString().contains(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String itemStackArrayToBase64(ItemStack[] itemArray) throws IllegalStateException {
|
||||
try {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
|
||||
|
||||
dataOutput.writeObject(itemArray);
|
||||
|
||||
dataOutput.close();
|
||||
|
||||
return Base64Coder.encodeLines(outputStream.toByteArray());
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Error whilst saving items, Please contact the developer", e);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
|
||||
try {
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
||||
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
|
||||
|
||||
ItemStack[] itemArray = (ItemStack[]) dataInput.readObject();
|
||||
|
||||
dataInput.close();
|
||||
return itemArray;
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IOException("Error whilst loading items, Please contact the developer", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
313
betterhoppers/src/main/java/de/hessj/betterhoppers/BetterHopperListener.java
Executable file
313
betterhoppers/src/main/java/de/hessj/betterhoppers/BetterHopperListener.java
Executable file
@@ -0,0 +1,313 @@
|
||||
package de.hessj.betterhoppers;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class BetterHopperListener implements Listener {
|
||||
Component inventoryname = Component.text("Items zum filtern:");
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
|
||||
if (App.main.checkFilterHopper(e.getItemInHand())) {
|
||||
Location loc = e.getBlockPlaced().getLocation();
|
||||
InventoryHolder invh = (InventoryHolder) e.getBlockPlaced().getState();
|
||||
Inventory newHopperinv = Bukkit.createInventory(invh, 9);
|
||||
App.main.getConfig()
|
||||
.set("hoppers." + loc.getWorld().getName() + "." + loc.getBlockX() + "~"
|
||||
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory",
|
||||
App.main.itemStackArrayToBase64(newHopperinv.getContents()));
|
||||
App.main.saveConfig();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent e) throws IllegalArgumentException, IOException {
|
||||
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.AIR && e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getPlayer().isSneaking()
|
||||
&& e.getClickedBlock().getType().equals(Material.HOPPER)) {
|
||||
e.setCancelled(true);
|
||||
if (App.main.getConfig().getConfigurationSection("hoppers") != null) {
|
||||
|
||||
String w = e.getClickedBlock().getWorld().getName();
|
||||
Location loc = e.getClickedBlock().getLocation();
|
||||
|
||||
if (App.main.getConfig().get("hoppers." + w + "." + loc.getBlockX() + "~" + loc.getBlockY() + "~"
|
||||
+ loc.getBlockZ()) != null) {
|
||||
InventoryHolder invh = (InventoryHolder) e.getClickedBlock().getState();
|
||||
|
||||
Inventory hopperinv = Bukkit.createInventory(invh, 9, inventoryname);
|
||||
hopperinv.setContents(App.main.itemStackArrayFromBase64(
|
||||
App.main.getConfig().getString("hoppers." + w + "." + loc.getBlockX() + "~"
|
||||
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory")));
|
||||
e.getPlayer().openInventory(hopperinv);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInvClose(InventoryCloseEvent e) {
|
||||
if (e.getView().title().equals(inventoryname)) {
|
||||
Inventory invtosave = e.getInventory();
|
||||
InventoryHolder invholder = e.getInventory().getHolder();
|
||||
Location loc = invholder.getInventory().getLocation();
|
||||
App.main.getConfig()
|
||||
.set("hoppers." + loc.getWorld().getName() + "." + loc.getBlockX() + "~"
|
||||
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory",
|
||||
App.main.itemStackArrayToBase64(invtosave.getContents()));
|
||||
App.main.saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
Inventory top = e.getView().getTopInventory();
|
||||
Inventory bottom = e.getView().getBottomInventory();
|
||||
if (e.getView().title().equals(inventoryname)) {
|
||||
e.setCancelled(true);
|
||||
if (e.getClickedInventory() == top) {
|
||||
if (top.getItem(e.getSlot()) != null) {
|
||||
top.setItem(e.getSlot(), null);
|
||||
}
|
||||
} else if (e.getClickedInventory() == bottom) {
|
||||
if (bottom.getItem(e.getSlot()) != null) {
|
||||
if (top.firstEmpty() != -1) {
|
||||
ItemStack is = bottom.getItem(e.getSlot()).clone();
|
||||
is.setAmount(1);
|
||||
if (!top.containsAtLeast(is, 1)) {// if top hat das item noch nicht dann nur adden
|
||||
|
||||
top.addItem(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
if (e.getPlayer() != null && e.getPlayer().getGameMode() == GameMode.SURVIVAL) {
|
||||
if (e.getBlock().getType() == Material.HOPPER) {
|
||||
Location loc = e.getBlock().getLocation();
|
||||
if (App.main.getConfig()
|
||||
.contains("hoppers." + loc.getWorld().getName() + "." + loc.getBlockX() + "~"
|
||||
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory")) {
|
||||
|
||||
App.main.getConfig().getConfigurationSection("hoppers")
|
||||
.set(loc.getWorld().getName() + "." + loc.getBlockX() + "~"
|
||||
+ loc.getBlockY() + "~" + loc.getBlockZ(), null);
|
||||
App.main.saveConfig();
|
||||
e.setCancelled(true);
|
||||
e.getBlock().setType(Material.AIR);
|
||||
e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(),
|
||||
new ItemStack(Material.HOPPER, 1));
|
||||
e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(),
|
||||
new ItemStack(Material.COMPARATOR, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(EntityExplodeEvent e) {
|
||||
for (Block b : e.blockList()) {
|
||||
if (b.getType() == Material.HOPPER) {
|
||||
Location loc = b.getLocation();
|
||||
if (App.main.getConfig()
|
||||
.contains("hoppers." + loc.getWorld().getName() + "." + loc.getBlockX() + "~"
|
||||
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory")) {
|
||||
App.main.getConfig().getConfigurationSection("hoppers")
|
||||
.set(loc.getWorld().getName() + "." + loc.getBlockX() + "~"
|
||||
+ loc.getBlockY() + "~" + loc.getBlockZ(), null);
|
||||
App.main.saveConfig();
|
||||
b.setType(Material.AIR);
|
||||
b.getWorld().dropItemNaturally(loc, new ItemStack(Material.HOPPER, 1));
|
||||
b.getWorld().dropItemNaturally(loc, new ItemStack(Material.COMPARATOR, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryPickupEvent(InventoryPickupItemEvent event) throws IllegalArgumentException, IOException {
|
||||
Inventory dest = event.getInventory();
|
||||
Location loc = dest.getLocation();
|
||||
if (App.main.getConfig()
|
||||
.contains("hoppers." + loc.getWorld().getName() + "." + loc.getBlockX() + "~"
|
||||
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory")) {
|
||||
|
||||
InventoryHolder invh = (InventoryHolder) event.getInventory().getLocation().getWorld()
|
||||
.getBlockAt(event.getInventory().getLocation()).getState();
|
||||
|
||||
Inventory hopperinv = Bukkit.createInventory(invh, 9, inventoryname);
|
||||
hopperinv.setContents(App.main.itemStackArrayFromBase64(
|
||||
App.main.getConfig().getString("hoppers." + loc.getWorld().getName() + "." + loc.getBlockX() + "~"
|
||||
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory")));
|
||||
|
||||
if (!checkSimilarity(event.getItem().getItemStack().getType(), hopperinv)) {
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled=true)
|
||||
public void onItemMove(InventoryMoveItemEvent e) throws IllegalArgumentException, IOException {
|
||||
Inventory dest = e.getDestination();
|
||||
if(dest.getLocation() != null){
|
||||
Location destLoc = dest.getLocation();
|
||||
Inventory source = e.getSource();
|
||||
|
||||
|
||||
|
||||
if (App.main.getConfig()
|
||||
.contains("hoppers." + destLoc.getWorld().getName() + "." + destLoc.getBlockX() + "~"
|
||||
+ destLoc.getBlockY() + "~" + destLoc.getBlockZ() + ".filterinventory")) {
|
||||
|
||||
|
||||
InventoryHolder invh = (InventoryHolder) destLoc.getWorld().getBlockAt(destLoc).getState();
|
||||
Inventory filterInv = Bukkit.createInventory(invh, 9, inventoryname);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
filterInv.setContents(App.main.itemStackArrayFromBase64(
|
||||
App.main.getConfig().getString("hoppers." + destLoc.getWorld().getName() + "." + destLoc.getBlockX() + "~"
|
||||
+ destLoc.getBlockY() + "~" + destLoc.getBlockZ() + ".filterinventory")));
|
||||
|
||||
|
||||
|
||||
if(!filterInv.contains(e.getItem().getType())){
|
||||
e.setCancelled(true);
|
||||
|
||||
for (int slot = 1; slot < source.getSize(); slot++) {
|
||||
if(source.getItem(slot) != null){
|
||||
ItemStack temp = source.getItem(slot).clone();
|
||||
temp.setAmount(1);
|
||||
if(filterInv.containsAtLeast(temp,1)){
|
||||
moveItem(source, slot, dest);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void moveItem(Inventory source, Integer slot, Inventory dest){
|
||||
Boolean freespace = false;
|
||||
ItemStack i = source.getItem(slot);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (ItemStack is : dest.getContents()) {
|
||||
if (is != null) {
|
||||
if (is.isSimilar(i)) {
|
||||
|
||||
if (is.getAmount() == is.getMaxStackSize()) {
|
||||
// nix tun
|
||||
} else {
|
||||
is.setAmount(is.getAmount()+1);
|
||||
i.setAmount(i.getAmount()-1);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
freespace = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (freespace) {
|
||||
ItemStack iClone = i.clone();
|
||||
iClone.setAmount(1);
|
||||
dest.setItem(dest.firstEmpty(), iClone);
|
||||
i.setAmount(i.getAmount()-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static boolean checkSimilarity(Material material, Inventory inv) {
|
||||
|
||||
for (ItemStack itemstack : inv.getContents()) {
|
||||
if (itemstack == null) {
|
||||
continue;
|
||||
}
|
||||
if (material.equals(itemstack.getType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
13
betterhoppers/src/main/java/de/hessj/betterhoppers/LoginListener.java
Executable file
13
betterhoppers/src/main/java/de/hessj/betterhoppers/LoginListener.java
Executable file
@@ -0,0 +1,13 @@
|
||||
package de.hessj.betterhoppers;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
public class LoginListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(PlayerLoginEvent e){
|
||||
e.getPlayer().discoverRecipe(App.main.nskHopper);
|
||||
}
|
||||
}
|
||||
5
betterhoppers/src/main/resources/plugin.yml
Executable file
5
betterhoppers/src/main/resources/plugin.yml
Executable file
@@ -0,0 +1,5 @@
|
||||
main: de.hessj.betterhoppers.App
|
||||
name: BetterHoppersPlugin
|
||||
depend: [HelperPlugin]
|
||||
version: 0.1
|
||||
api-version: 1.19
|
||||
BIN
betterhoppers/target/betterhoppers-1.0-SNAPSHOT.jar
Executable file
BIN
betterhoppers/target/betterhoppers-1.0-SNAPSHOT.jar
Executable file
Binary file not shown.
BIN
betterhoppers/target/classes/de/hessj/betterhoppers/App.class
Executable file
BIN
betterhoppers/target/classes/de/hessj/betterhoppers/App.class
Executable file
Binary file not shown.
BIN
betterhoppers/target/classes/de/hessj/betterhoppers/BetterHopperListener.class
Executable file
BIN
betterhoppers/target/classes/de/hessj/betterhoppers/BetterHopperListener.class
Executable file
Binary file not shown.
BIN
betterhoppers/target/classes/de/hessj/betterhoppers/LoginListener.class
Executable file
BIN
betterhoppers/target/classes/de/hessj/betterhoppers/LoginListener.class
Executable file
Binary file not shown.
5
betterhoppers/target/maven-archiver/pom.properties
Executable file
5
betterhoppers/target/maven-archiver/pom.properties
Executable file
@@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Mon Jul 11 16:37:13 CEST 2022
|
||||
groupId=de.hessj.betterhoppers
|
||||
artifactId=betterhoppers
|
||||
version=1.0-SNAPSHOT
|
||||
@@ -0,0 +1,3 @@
|
||||
/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/betterhoppers/src/main/java/de/hessj/betterhoppers/App.java
|
||||
/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/betterhoppers/src/main/java/de/hessj/betterhoppers/LoginListener.java
|
||||
/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/betterhoppers/src/main/java/de/hessj/betterhoppers/BetterHopperListener.java
|
||||
71
chestex/pom.xml
Executable file
71
chestex/pom.xml
Executable file
@@ -0,0 +1,71 @@
|
||||
<?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.hessj.chestex</groupId>
|
||||
<artifactId>chestex</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.20-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>mc-api</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/CraftBukkit.jar</systemPath>
|
||||
<!--systemPath>\\fileserver\Janik\DOKUMENTE\Programmierung\MCServer\MCPlugins\CraftBukkit.jar</systemPath>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hessj.helper</groupId>
|
||||
<artifactId>helper</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<!--<systemPath>\\fileserver\Janik\DOKUMENTE\Programmierung\MCServer\MCPlugins\helper\target\helper-1.0-SNAPSHOT.jar</systemPath>-->
|
||||
<systemPath>/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/helper/target/helper-1.0-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<outputDirectory>/mnt/minecrafttest/plugins</outputDirectory>
|
||||
<!--<outputDirectory>\\fileserver\MinecraftTEST\plugins</outputDirectory>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
56
chestex/src/main/java/de/hessj/chestex/App.java
Executable file
56
chestex/src/main/java/de/hessj/chestex/App.java
Executable file
@@ -0,0 +1,56 @@
|
||||
package de.hessj.chestex;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class App extends JavaPlugin {
|
||||
public static App main;
|
||||
public de.hessj.helper.Helper helper= new de.hessj.helper.Helper();
|
||||
public NamespacedKey nskLockedChest = new NamespacedKey(this, "R3SLockedChest");
|
||||
public NamespacedKey nskLockedChestRecipe = new NamespacedKey(this, "R3SLockedChestRecipe");
|
||||
public ItemStack lockedChest;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("Plugin enabled!");
|
||||
main = this;
|
||||
|
||||
|
||||
lockedChest = new ItemStack(Material.CHEST);
|
||||
ItemMeta imlockedChest = lockedChest.getItemMeta();
|
||||
imlockedChest.displayName(Component.translatable(ChatColor.AQUA + "Verschlossene Truhe"));
|
||||
imlockedChest.getPersistentDataContainer().set(nskLockedChest, PersistentDataType.STRING, "R3S_LockedChest");
|
||||
lockedChest.setItemMeta(imlockedChest);
|
||||
ShapedRecipe safechestRecipe = new ShapedRecipe(nskLockedChestRecipe, lockedChest);
|
||||
RecipeChoice rc = new RecipeChoice.MaterialChoice(Material.OAK_LOG, Material.SPRUCE_LOG, Material.BIRCH_LOG,
|
||||
Material.JUNGLE_LOG, Material.ACACIA_LOG, Material.DARK_OAK_LOG);
|
||||
safechestRecipe.shape("LLL", "LKL", "III");
|
||||
safechestRecipe.setIngredient('L', rc);
|
||||
safechestRecipe.setIngredient('K', Material.TRIPWIRE_HOOK);
|
||||
safechestRecipe.setIngredient('I', Material.IRON_INGOT);
|
||||
if (getServer().getRecipe(nskLockedChestRecipe) == null) {
|
||||
App.main.getServer().addRecipe(safechestRecipe);
|
||||
}
|
||||
listenerRegistration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Plugin disabled!");
|
||||
}
|
||||
|
||||
private void listenerRegistration() {
|
||||
PluginManager pM = Bukkit.getPluginManager();
|
||||
pM.registerEvents(new SafeChestListener(), this);
|
||||
}
|
||||
}
|
||||
318
chestex/src/main/java/de/hessj/chestex/SafeChestListener.java
Executable file
318
chestex/src/main/java/de/hessj/chestex/SafeChestListener.java
Executable file
@@ -0,0 +1,318 @@
|
||||
package de.hessj.chestex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import de.hessj.helper.Helper.Type;
|
||||
|
||||
public class SafeChestListener implements Listener {
|
||||
public Boolean lastPlacedIsSafeChest = false;
|
||||
public de.hessj.helper.Helper helper= new de.hessj.helper.Helper();
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
e.getPlayer().discoverRecipe(App.main.nskLockedChestRecipe);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && !e.getClickedBlock().getType().isInteractable()) {
|
||||
if (e.getPlayer().getInventory().getItemInMainHand() != null
|
||||
&& e.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && e.getPlayer().getInventory()
|
||||
.getItemInMainHand().getItemMeta().getPersistentDataContainer() != null) {
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer()
|
||||
.has(App.main.nskLockedChest, PersistentDataType.STRING)) {
|
||||
lastPlacedIsSafeChest = true;
|
||||
}
|
||||
}
|
||||
} else if (e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getClickedBlock().getType().isInteractable()) {
|
||||
Location loc = e.getClickedBlock().getLocation();
|
||||
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
|
||||
if (App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())
|
||||
.contains(locStr)) {
|
||||
// is meine truhe
|
||||
} else {
|
||||
if (App.main.getConfig().getConfigurationSection("chests") != null) {
|
||||
for (String uuid : App.main.getConfig().getConfigurationSection("chests").getKeys(false)) {
|
||||
List<String> chestList = App.main.getConfig().getStringList("chests." + uuid);
|
||||
if (chestList.contains(locStr)) {
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Dies ist nicht deine Truhe!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlace(BlockPlaceEvent e) {
|
||||
if (e.getBlockPlaced().getType().equals(Material.CHEST) && lastPlacedIsSafeChest) {
|
||||
|
||||
Chest chest = (Chest) e.getBlock().getState();
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(App.main, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
InventoryHolder holder = chest.getInventory().getHolder();
|
||||
|
||||
if (holder instanceof DoubleChest) {
|
||||
DoubleChest doubleChest = ((DoubleChest) holder);
|
||||
Chest leftChest = (Chest) doubleChest.getLeftSide();
|
||||
Chest rightChest = (Chest) doubleChest.getRightSide();
|
||||
|
||||
// WENN HIER DIE EINE IN CONFIG GEHÖRT PLAYER
|
||||
|
||||
if (leftChest.getLocation().equals(e.getBlockPlaced().getLocation())) {
|
||||
// rechte checken
|
||||
Location loc = rightChest.getLocation();
|
||||
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
|
||||
|
||||
if (!App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())
|
||||
.contains(locStr)) {
|
||||
e.getBlockPlaced().setType(Material.AIR);
|
||||
e.setCancelled(true);
|
||||
// HIER
|
||||
if (e.getHand() == EquipmentSlot.OFF_HAND) {
|
||||
if (e.getPlayer().getInventory().getItemInOffHand().getAmount() > 0) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(
|
||||
e.getPlayer().getInventory().getItemInOffHand().add(1));
|
||||
} else {
|
||||
e.getPlayer().getInventory().setItemInOffHand(App.main.lockedChest);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
} else if (e.getHand() == EquipmentSlot.HAND) {
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getAmount() > 0) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(
|
||||
e.getPlayer().getInventory().getItemInMainHand().add(1));
|
||||
|
||||
} else {
|
||||
e.getPlayer().getInventory().setItemInMainHand(App.main.lockedChest);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Du kannst diese Truhe nicht mit einer verschlossenen Truhe erweitern!"));
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (rightChest.getLocation().equals(e.getBlockPlaced().getLocation())) {
|
||||
// linke checken
|
||||
Location loc = leftChest.getLocation();
|
||||
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
|
||||
|
||||
if (!App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())
|
||||
.contains(locStr)) {
|
||||
e.getBlockPlaced().setType(Material.AIR);
|
||||
e.setCancelled(true);
|
||||
// HIER
|
||||
if (e.getHand() == EquipmentSlot.OFF_HAND) {
|
||||
if (e.getPlayer().getInventory().getItemInOffHand().getAmount() > 0) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(
|
||||
e.getPlayer().getInventory().getItemInOffHand().add(1));
|
||||
} else {
|
||||
e.getPlayer().getInventory().setItemInOffHand(App.main.lockedChest);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
} else if (e.getHand() == EquipmentSlot.HAND) {
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getAmount() > 0) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(
|
||||
e.getPlayer().getInventory().getItemInMainHand().add(1));
|
||||
|
||||
} else {
|
||||
e.getPlayer().getInventory().setItemInMainHand(App.main.lockedChest);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Du kannst diese Truhe nicht mit einer verschlossenen Truhe erweitern!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// HIER IN DING EINTRAGEN
|
||||
Location loc = e.getBlockPlaced().getLocation();
|
||||
List<String> chestList = App.main.getConfig()
|
||||
.getStringList("chests." + e.getPlayer().getUniqueId().toString());
|
||||
chestList.add(loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ());
|
||||
App.main.getConfig().set("chests." + e.getPlayer().getUniqueId().toString(), chestList);
|
||||
|
||||
App.main.saveConfig();
|
||||
|
||||
lastPlacedIsSafeChest = false;
|
||||
}
|
||||
}, 1L);
|
||||
|
||||
} else if (e.getBlockPlaced().getType().equals(Material.CHEST) && !lastPlacedIsSafeChest) {
|
||||
Chest chest = (Chest) e.getBlock().getState();
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(App.main, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
InventoryHolder holder = chest.getInventory().getHolder();
|
||||
|
||||
if (holder instanceof DoubleChest) {
|
||||
DoubleChest doubleChest = ((DoubleChest) holder);
|
||||
Chest leftChest = (Chest) doubleChest.getLeftSide();
|
||||
Chest rightChest = (Chest) doubleChest.getRightSide();
|
||||
|
||||
// WENN HIER DIE EINE IN CONFIG GEHÖRT PLAYER
|
||||
|
||||
if (leftChest.getLocation().equals(e.getBlockPlaced().getLocation())) {
|
||||
// rechte checken
|
||||
Location loc = rightChest.getLocation();
|
||||
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
|
||||
|
||||
if (App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())
|
||||
.contains(locStr)) {
|
||||
e.getBlockPlaced().setType(Material.AIR);
|
||||
e.setCancelled(true);
|
||||
// HIER
|
||||
if (e.getHand() == EquipmentSlot.OFF_HAND) {
|
||||
if (e.getPlayer().getInventory().getItemInOffHand().getAmount() > 0) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(
|
||||
e.getPlayer().getInventory().getItemInOffHand().add(1));
|
||||
} else {
|
||||
e.getPlayer().getInventory().setItemInOffHand(App.main.lockedChest);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
} else if (e.getHand() == EquipmentSlot.HAND) {
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getAmount() > 0) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(
|
||||
e.getPlayer().getInventory().getItemInMainHand().add(1));
|
||||
|
||||
} else {
|
||||
e.getPlayer().getInventory().setItemInMainHand(App.main.lockedChest);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
}
|
||||
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Du kannst eine verschlossene Truhe nicht mit einer anderen Truhe erweitern!"));
|
||||
|
||||
}
|
||||
|
||||
} else if (rightChest.getLocation().equals(e.getBlockPlaced().getLocation())) {
|
||||
// linke checken
|
||||
Location loc = leftChest.getLocation();
|
||||
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
|
||||
|
||||
if (App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())
|
||||
.contains(locStr)) {
|
||||
e.getBlockPlaced().setType(Material.AIR);
|
||||
e.setCancelled(true);
|
||||
// HIER
|
||||
if (e.getHand() == EquipmentSlot.OFF_HAND) {
|
||||
if (e.getPlayer().getInventory().getItemInOffHand().getAmount() > 0) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(
|
||||
e.getPlayer().getInventory().getItemInOffHand().add(1));
|
||||
} else {
|
||||
e.getPlayer().getInventory().setItemInOffHand(App.main.lockedChest);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
} else if (e.getHand() == EquipmentSlot.HAND) {
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getAmount() > 0) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(
|
||||
e.getPlayer().getInventory().getItemInMainHand().add(1));
|
||||
} else {
|
||||
e.getPlayer().getInventory().setItemInMainHand(App.main.lockedChest);
|
||||
e.getPlayer().updateInventory();
|
||||
}
|
||||
}
|
||||
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Du kannst eine verschlossene Truhe nicht mit einer anderen Truhe erweitern!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1L);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplodeEvent(EntityExplodeEvent event) {
|
||||
List<Block> safelist = new ArrayList<Block>();
|
||||
for (Block block : event.blockList()) {
|
||||
if (block.getType() == Material.CHEST) {
|
||||
if (App.main.getConfig().getConfigurationSection("chests") != null) {
|
||||
Location loc = block.getLocation();
|
||||
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
|
||||
for (String uuid : App.main.getConfig().getConfigurationSection("chests").getKeys(false)) {
|
||||
List<String> chestList = App.main.getConfig().getStringList("chests." + uuid);
|
||||
if (chestList.contains(locStr)) {
|
||||
safelist.add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Block b : safelist) {
|
||||
event.blockList().remove(b);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDestroy(BlockBreakEvent e) {
|
||||
if (!e.getBlock().getType().equals(Material.CHEST)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = e.getBlock().getLocation();
|
||||
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
|
||||
if (App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString()).contains(locStr)) {
|
||||
List<String> chestList = App.main.getConfig()
|
||||
.getStringList("chests." + e.getPlayer().getUniqueId().toString());
|
||||
chestList.remove(locStr);
|
||||
App.main.getConfig().set("chests." + e.getPlayer().getUniqueId().toString(), chestList);
|
||||
App.main.saveConfig();
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
Chest c = (Chest) e.getBlock().getState();
|
||||
|
||||
for (ItemStack is : c.getBlockInventory()) {
|
||||
if (is != null) {
|
||||
|
||||
e.getBlock().getWorld().dropItemNaturally(loc, is);
|
||||
}
|
||||
}
|
||||
e.getBlock().setType(Material.AIR);
|
||||
|
||||
e.getBlock().getWorld().dropItem(loc, App.main.lockedChest);
|
||||
} else {
|
||||
if (App.main.getConfig().getConfigurationSection("chests") != null) {
|
||||
for (String uuid : App.main.getConfig().getConfigurationSection("chests").getKeys(false)) {
|
||||
List<String> chestList = App.main.getConfig().getStringList("chests." + uuid);
|
||||
if (chestList.contains(locStr)) {
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Dies ist nicht deine Truhe!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
5
chestex/src/main/resources/plugin.yml
Executable file
5
chestex/src/main/resources/plugin.yml
Executable file
@@ -0,0 +1,5 @@
|
||||
main: de.hessj.chestex.App
|
||||
name: ChestExPlugin
|
||||
version: 0.1
|
||||
api-version: 1.19
|
||||
depend: [HelperPlugin]
|
||||
BIN
chestex/target/chestex-1.0-SNAPSHOT.jar
Executable file
BIN
chestex/target/chestex-1.0-SNAPSHOT.jar
Executable file
Binary file not shown.
BIN
chestex/target/classes/de/hessj/chestex/App.class
Executable file
BIN
chestex/target/classes/de/hessj/chestex/App.class
Executable file
Binary file not shown.
BIN
chestex/target/classes/de/hessj/chestex/SafeChestListener$1.class
Executable file
BIN
chestex/target/classes/de/hessj/chestex/SafeChestListener$1.class
Executable file
Binary file not shown.
BIN
chestex/target/classes/de/hessj/chestex/SafeChestListener$2.class
Executable file
BIN
chestex/target/classes/de/hessj/chestex/SafeChestListener$2.class
Executable file
Binary file not shown.
BIN
chestex/target/classes/de/hessj/chestex/SafeChestListener.class
Executable file
BIN
chestex/target/classes/de/hessj/chestex/SafeChestListener.class
Executable file
Binary file not shown.
5
chestex/target/classes/plugin.yml
Executable file
5
chestex/target/classes/plugin.yml
Executable file
@@ -0,0 +1,5 @@
|
||||
main: de.hessj.chestex.App
|
||||
name: ChestExPlugin
|
||||
version: 0.1
|
||||
api-version: 1.19
|
||||
depend: [HelperPlugin]
|
||||
5
chestex/target/maven-archiver/pom.properties
Executable file
5
chestex/target/maven-archiver/pom.properties
Executable file
@@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Mon Jun 27 18:49:04 CEST 2022
|
||||
groupId=de.hessj.chestex
|
||||
artifactId=chestex
|
||||
version=1.0-SNAPSHOT
|
||||
@@ -0,0 +1,2 @@
|
||||
/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/chestex/src/main/java/de/hessj/chestex/App.java
|
||||
/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/chestex/src/main/java/de/hessj/chestex/SafeChestListener.java
|
||||
70
dailyquests/pom.xml
Executable file
70
dailyquests/pom.xml
Executable file
@@ -0,0 +1,70 @@
|
||||
<?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.hessj.dailyquests</groupId>
|
||||
<artifactId>dailyquests</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies> <dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.20-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>mc-api</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/CraftBukkit.jar</systemPath>
|
||||
<!--systemPath>\\fileserver\Janik\DOKUMENTE\Programmierung\MCServer\MCPlugins\CraftBukkit.jar</systemPath>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hessj.helper</groupId>
|
||||
<artifactId>helper</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<!--<systemPath>\\fileserver\Janik\DOKUMENTE\Programmierung\MCServer\MCPlugins\helper\target\helper-1.0-SNAPSHOT.jar</systemPath>-->
|
||||
<systemPath>/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/helper/target/helper-1.0-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<outputDirectory>/mnt/minecrafttest/plugins</outputDirectory>
|
||||
<!--<outputDirectory>\\fileserver\MinecraftTEST\plugins</outputDirectory>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
133
dailyquests/src/main/java/de/hessj/dailyquests/App.java
Executable file
133
dailyquests/src/main/java/de/hessj/dailyquests/App.java
Executable file
@@ -0,0 +1,133 @@
|
||||
package de.hessj.dailyquests;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.Map.Entry;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import de.hessj.helper.Helper.Type;
|
||||
|
||||
public class App extends JavaPlugin {
|
||||
public static App main;
|
||||
public de.hessj.helper.Helper helper = new de.hessj.helper.Helper();
|
||||
public ArrayList<ItemStack> rewardList = new ArrayList<ItemStack>();
|
||||
public ItemStack diamondDust;
|
||||
public NamespacedKey nskdiamondDust;
|
||||
public NamespacedKey nskDD = new NamespacedKey(this, "R3S_SR_DIAMONDDUST");
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("Plugin enabled!");
|
||||
main = this;
|
||||
setupRewards();
|
||||
DailyQuestsListeners.getTodaysQuest();
|
||||
LocalDateTime start = LocalDateTime.now();
|
||||
LocalDateTime nextMidnight = start.plusDays(1).withHour(0).withMinute(0).withSecond(0);
|
||||
ZonedDateTime zdt = ZonedDateTime.of(nextMidnight, ZoneId.of("Europe/Berlin"));
|
||||
Duration duration = Duration.between(start, zdt);
|
||||
long secUntil = duration.toMillis() / 1000;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
resetQuestScheduler();
|
||||
}
|
||||
}, 20 * secUntil); // Wird beim nächsten 0Uhr ausgeführt
|
||||
|
||||
listenerRegistration();
|
||||
}
|
||||
|
||||
public void resetQuestScheduler() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getConfig().set("players", null);
|
||||
saveConfig();
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
DailyQuestsListeners.getDailyQuests(p);
|
||||
Entry<Scoreboard, Boolean> actionMapEntry = DailyQuestsCommands.boards.get(p.getName());
|
||||
Scoreboard board = actionMapEntry.getKey();
|
||||
if (!actionMapEntry.getValue()) {
|
||||
p.setScoreboard(Bukkit.getServer().getScoreboardManager().getNewScoreboard());
|
||||
DailyQuestsCommands.boards.put(p.getName(), new SimpleEntry<Scoreboard, Boolean>(board, false));
|
||||
} else {
|
||||
p.setScoreboard(Bukkit.getServer().getScoreboardManager().getNewScoreboard());
|
||||
p.setScoreboard(board);
|
||||
|
||||
DailyQuestsCommands.boards.put(p.getName(), new SimpleEntry<Scoreboard, Boolean>(board, true));
|
||||
}
|
||||
p.sendMessage(helper.R3SMessage(Type.INFO, "[DailyQuests] Du hast eine neue Quest erhalten!"));
|
||||
}
|
||||
saveConfig();
|
||||
}
|
||||
}, 0L, (24 * 60 * 60) * 20L); // Alle 24std neue Quest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Plugin disabled!");
|
||||
}
|
||||
|
||||
private void listenerRegistration() {
|
||||
PluginManager pM = Bukkit.getPluginManager();
|
||||
pM.registerEvents(new DailyQuestsListeners(), this);
|
||||
getCommand("quest").setExecutor(new DailyQuestsCommands());
|
||||
}
|
||||
|
||||
private void setupRewards() {
|
||||
|
||||
nskdiamondDust = new NamespacedKey(App.main, "R3SDiamondDust");
|
||||
diamondDust = new ItemStack(Material.BARRIER);
|
||||
ItemMeta mdiamondDust = diamondDust.getItemMeta();
|
||||
mdiamondDust.setCustomModelData(1000010);
|
||||
mdiamondDust.displayName(Component.translatable(ChatColor.WHITE + "Diamant-Staub"));
|
||||
mdiamondDust.getPersistentDataContainer().set(nskdiamondDust, PersistentDataType.STRING, "R3SDiamondDust");
|
||||
diamondDust.setItemMeta(mdiamondDust);
|
||||
RecipeChoice rc = new RecipeChoice.ExactChoice(diamondDust);
|
||||
ShapedRecipe ddRecipe = new ShapedRecipe(nskDD,
|
||||
new ItemStack(Material.DIAMOND));
|
||||
ddRecipe.shape("** ", "** ", " ");
|
||||
ddRecipe.setIngredient('*', rc);
|
||||
if (getServer().getRecipe(nskDD) == null) {
|
||||
App.main.getServer().addRecipe(ddRecipe);
|
||||
}
|
||||
rewardList.add(new ItemStack(Material.EXPERIENCE_BOTTLE, 1));
|
||||
rewardList.add(new ItemStack(Material.APPLE, 10));
|
||||
rewardList.add(new ItemStack(Material.POTATO, 5));
|
||||
rewardList.add(new ItemStack(Material.CARROT, 5));
|
||||
rewardList.add(new ItemStack(Material.COOKED_BEEF, 10));
|
||||
rewardList.add(new ItemStack(Material.COOKED_CHICKEN, 10));
|
||||
rewardList.add(new ItemStack(Material.COOKED_CHICKEN, 10));
|
||||
rewardList.add(new ItemStack(Material.COOKED_COD, 10));
|
||||
rewardList.add(new ItemStack(Material.COOKED_MUTTON, 10));
|
||||
rewardList.add(new ItemStack(Material.COOKED_PORKCHOP, 10));
|
||||
rewardList.add(new ItemStack(Material.COOKED_RABBIT, 10));
|
||||
rewardList.add(new ItemStack(Material.COOKED_SALMON, 10));
|
||||
rewardList.add(new ItemStack(Material.IRON_INGOT, 5));
|
||||
rewardList.add(new ItemStack(Material.COPPER_INGOT, 5));
|
||||
rewardList.add(new ItemStack(Material.GOLD_NUGGET, 5));
|
||||
rewardList.add(new ItemStack(Material.FIREWORK_ROCKET, 5));
|
||||
rewardList.add(new ItemStack(Material.SADDLE, 1));
|
||||
rewardList.add(new ItemStack(Material.MELON_SEEDS, 5));
|
||||
rewardList.add(new ItemStack(Material.PUMPKIN_SEEDS, 5));
|
||||
rewardList.add(new ItemStack(Material.BEETROOT_SEEDS, 5));
|
||||
rewardList.add(new ItemStack(Material.DIAMOND, 1));
|
||||
rewardList.add(new ItemStack(Material.CAKE, 1));
|
||||
rewardList.add(new ItemStack(Material.ENDER_PEARL, 5));
|
||||
}
|
||||
}
|
||||
195
dailyquests/src/main/java/de/hessj/dailyquests/DailyQuestsCommands.java
Executable file
195
dailyquests/src/main/java/de/hessj/dailyquests/DailyQuestsCommands.java
Executable file
@@ -0,0 +1,195 @@
|
||||
package de.hessj.dailyquests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.Map.Entry;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
|
||||
import de.hessj.helper.Helper.Type;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Score;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class DailyQuestsCommands implements CommandExecutor {
|
||||
|
||||
public static HashMap<String, Entry<Scoreboard, Boolean>> boards = new HashMap<String, Entry<Scoreboard, Boolean>>();
|
||||
public static NamespacedKey nsksurpriseBox;
|
||||
public static ItemStack surpriseBox;
|
||||
public static de.hessj.helper.Helper helper = new de.hessj.helper.Helper();
|
||||
|
||||
public static void updateSB(Player p) {
|
||||
if (!(boards.containsKey(p.getName()))) {
|
||||
|
||||
Scoreboard board = Bukkit.getServer().getScoreboardManager().getNewScoreboard();
|
||||
boards.put(p.getName(), new SimpleEntry<Scoreboard, Boolean>(board, false));
|
||||
}
|
||||
Entry<Scoreboard, Boolean> actionMapEntry = boards.get(p.getName());
|
||||
Scoreboard board = actionMapEntry.getKey();
|
||||
|
||||
if (board.getObjective(DisplaySlot.SIDEBAR) != null) {
|
||||
board.getObjective(DisplaySlot.SIDEBAR).unregister();
|
||||
}
|
||||
Objective o = board.registerNewObjective("test", "dummy", Component.text("Quest:"));
|
||||
|
||||
|
||||
o.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
Score score;
|
||||
for (Object obj : App.main.getConfig().getConfigurationSection("players." + p.getUniqueId() + ".currentQuests")
|
||||
.getKeys(false).toArray()) {
|
||||
|
||||
if (!obj.toString().equals("null")) {
|
||||
String desc = "";
|
||||
if (!App.main.getConfig().get("quests." + obj.toString() + ".tool").equals("none")) {
|
||||
desc = (App.main.getConfig().get("quests." + obj.toString() + ".description")).toString()
|
||||
.replace("[x]",
|
||||
App.main.getConfig()
|
||||
.get("players." + p.getUniqueId() + ".currentQuests." + obj.toString()
|
||||
+ ".countneeded")
|
||||
.toString()/*
|
||||
* App.main.getConfig().get("quests." + obj.toString() +
|
||||
* ".count").toString()
|
||||
*/)
|
||||
.replace("[b]", App.main.getConfig().get("quests." + obj.toString() + ".target").toString())
|
||||
.replace("[t]", App.main.getConfig().get("quests." + obj.toString() + ".tool").toString()
|
||||
.replace("Material.", ""));
|
||||
|
||||
} else {
|
||||
desc = App.main.getConfig().get("quests." + obj.toString() + ".description").toString()
|
||||
.replace("[x]",
|
||||
App.main.getConfig()
|
||||
.get("players." + p.getUniqueId() + ".currentQuests." + obj.toString()
|
||||
+ ".countneeded")
|
||||
.toString())
|
||||
.replace("[b]",
|
||||
App.main.getConfig().get("quests." + obj.toString() + ".target").toString());
|
||||
|
||||
}
|
||||
desc = desc.replace("Material.", "");
|
||||
if (desc.length() >= 39) {
|
||||
desc = desc.substring(0, 39);
|
||||
}
|
||||
if (App.main.getConfig()
|
||||
.get("players." + p.getUniqueId() + ".currentQuests." + obj.toString() + ".state")
|
||||
.equals("finished")) {
|
||||
board.resetScores(desc);
|
||||
score = o.getScore(ChatColor.STRIKETHROUGH + "" + desc);
|
||||
} else {
|
||||
score = o.getScore(desc);
|
||||
}
|
||||
score.setScore(App.main.getConfig()
|
||||
.getInt("players." + p.getUniqueId() + ".currentQuests." + obj.toString() + ".currentcount"));
|
||||
checkForCompletion(p);
|
||||
}
|
||||
}
|
||||
if (actionMapEntry.getValue()) {
|
||||
boards.put(p.getName(), new SimpleEntry<Scoreboard, Boolean>(board, true));
|
||||
} else {
|
||||
boards.put(p.getName(), new SimpleEntry<Scoreboard, Boolean>(board, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
updateSB((Player) sender);
|
||||
Entry<Scoreboard, Boolean> actionMapEntry = boards.get(((Player) sender).getName());
|
||||
Scoreboard board = actionMapEntry.getKey();
|
||||
if (actionMapEntry.getValue()) {
|
||||
((Player) sender).setScoreboard(Bukkit.getServer().getScoreboardManager().getNewScoreboard());
|
||||
boards.put(((Player) sender).getName(), new SimpleEntry<Scoreboard, Boolean>(board, false));
|
||||
} else {
|
||||
((Player) sender).setScoreboard(board);
|
||||
boards.put(((Player) sender).getName(), new SimpleEntry<Scoreboard, Boolean>(board, true));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void checkForCompletion(Player p) {
|
||||
int completed = 0;
|
||||
int all = 0;
|
||||
for (Object questIDs : App.main.getConfig().getConfigurationSection("quests").getKeys(false).toArray()) {
|
||||
if (App.main.getConfig()
|
||||
.contains("players." + p.getUniqueId().toString() + ".currentQuests." + questIDs.toString())) {
|
||||
if (App.main.getConfig().get(
|
||||
"players." + p.getUniqueId().toString() + ".currentQuests." + questIDs.toString() + ".state")
|
||||
.equals("finished")) {
|
||||
completed++;
|
||||
}
|
||||
all++;
|
||||
}
|
||||
}
|
||||
if (completed == all) {
|
||||
if (!App.main.getConfig().get("players." + p.getUniqueId().toString() + ".rewards").equals("claimed")) {
|
||||
|
||||
surpriseBox = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||
SkullMeta im = (SkullMeta) surpriseBox.getItemMeta();
|
||||
im.displayName(Component.translatable(ChatColor.WHITE + "Überraschungsbox"));
|
||||
im.setPlayerProfile(Bukkit.createProfile(UUID.randomUUID(), null));
|
||||
PlayerProfile playerProfile = im.getPlayerProfile();
|
||||
playerProfile.getProperties().add(new ProfileProperty("textures",
|
||||
"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDQxZmJlYTljMmQxOTA0MGU1NjdmMzg3YWI0NmIyZjhhM2ExZGE4ZWVjOWQzOTllMmU0YWRjZjA1YWRhOGEyYSJ9fX0="));
|
||||
im.setPlayerProfile(playerProfile);
|
||||
nsksurpriseBox = new NamespacedKey(App.main, "R3SSurpriseBox");
|
||||
im.getPersistentDataContainer().set(nsksurpriseBox, PersistentDataType.STRING, "R3S_SurpriseBox");
|
||||
ArrayList<Component> lore = new ArrayList<Component>();
|
||||
lore.add(Component.translatable("Quest Belohnung"));
|
||||
im.lore(lore);
|
||||
surpriseBox.setItemMeta(im);
|
||||
|
||||
Boolean freeSpace = false;
|
||||
Boolean given = false;
|
||||
for (ItemStack i : p.getInventory().getStorageContents()) {
|
||||
if (i != null) {
|
||||
|
||||
if (i.getType() == surpriseBox.getType() && i.hasItemMeta()
|
||||
&& i.getItemMeta().getPersistentDataContainer() != null) {
|
||||
if (i.getItemMeta().getPersistentDataContainer().has(nsksurpriseBox,
|
||||
PersistentDataType.STRING)) {
|
||||
if (i.getAmount() < 64) {
|
||||
i.setAmount(i.getAmount() + 1);
|
||||
given = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (i == null) {
|
||||
freeSpace = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!freeSpace && !given) {
|
||||
|
||||
p.sendMessage(helper.R3SMessage(Type.ERROR, "[DailyQuests] Dein Inventar ist voll, schaffe Platz und logge dich ein, deine Questbelohnung zu erhalten!"));
|
||||
} else {
|
||||
if (!given && freeSpace) {
|
||||
p.getInventory().addItem(surpriseBox);
|
||||
}
|
||||
p.sendMessage(
|
||||
helper.R3SMessage(Type.SUCCESS,"[DailyQuests] Du hast 1x Überraschungsbox als Questbelohnung erhalten!"));
|
||||
App.main.getConfig().set("players." + p.getUniqueId() + ".rewards", "claimed");
|
||||
App.main.saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1632
dailyquests/src/main/java/de/hessj/dailyquests/DailyQuestsListeners.java
Executable file
1632
dailyquests/src/main/java/de/hessj/dailyquests/DailyQuestsListeners.java
Executable file
File diff suppressed because it is too large
Load Diff
10
dailyquests/src/main/resources/plugin.yml
Executable file
10
dailyquests/src/main/resources/plugin.yml
Executable file
@@ -0,0 +1,10 @@
|
||||
main: de.hessj.dailyquests.App
|
||||
name: DailyQuestsPlugin
|
||||
version: 0.1
|
||||
api-version: 1.19
|
||||
depend: [HelperPlugin]
|
||||
|
||||
commands:
|
||||
quest:
|
||||
description: Zeigt die heutigen Quests an
|
||||
usage: /<command>
|
||||
BIN
dailyquests/target/classes/de/hessj/dailyquests/App$1.class
Executable file
BIN
dailyquests/target/classes/de/hessj/dailyquests/App$1.class
Executable file
Binary file not shown.
BIN
dailyquests/target/classes/de/hessj/dailyquests/App$2.class
Executable file
BIN
dailyquests/target/classes/de/hessj/dailyquests/App$2.class
Executable file
Binary file not shown.
BIN
dailyquests/target/classes/de/hessj/dailyquests/App.class
Executable file
BIN
dailyquests/target/classes/de/hessj/dailyquests/App.class
Executable file
Binary file not shown.
BIN
dailyquests/target/classes/de/hessj/dailyquests/DailyQuestsCommands.class
Executable file
BIN
dailyquests/target/classes/de/hessj/dailyquests/DailyQuestsCommands.class
Executable file
Binary file not shown.
BIN
dailyquests/target/classes/de/hessj/dailyquests/DailyQuestsListeners.class
Executable file
BIN
dailyquests/target/classes/de/hessj/dailyquests/DailyQuestsListeners.class
Executable file
Binary file not shown.
10
dailyquests/target/classes/plugin.yml
Executable file
10
dailyquests/target/classes/plugin.yml
Executable file
@@ -0,0 +1,10 @@
|
||||
main: de.hessj.dailyquests.App
|
||||
name: DailyQuestsPlugin
|
||||
version: 0.1
|
||||
api-version: 1.19
|
||||
depend: [HelperPlugin]
|
||||
|
||||
commands:
|
||||
quest:
|
||||
description: Zeigt die heutigen Quests an
|
||||
usage: /<command>
|
||||
BIN
dailyquests/target/dailyquests-1.0-SNAPSHOT.jar
Executable file
BIN
dailyquests/target/dailyquests-1.0-SNAPSHOT.jar
Executable file
Binary file not shown.
5
dailyquests/target/maven-archiver/pom.properties
Executable file
5
dailyquests/target/maven-archiver/pom.properties
Executable file
@@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Thu Jul 21 00:46:41 CEST 2022
|
||||
artifactId=dailyquests
|
||||
groupId=de.hessj.dailyquests
|
||||
version=1.0-SNAPSHOT
|
||||
@@ -0,0 +1,3 @@
|
||||
/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/dailyquests/src/main/java/de/hessj/dailyquests/DailyQuestsCommands.java
|
||||
/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/dailyquests/src/main/java/de/hessj/dailyquests/DailyQuestsListeners.java
|
||||
/mnt/janik/DOKUMENTE/Programmierung/MCServer/MCPlugins/dailyquests/src/main/java/de/hessj/dailyquests/App.java
|
||||
BIN
environmentex/.DS_Store
vendored
Executable file
BIN
environmentex/.DS_Store
vendored
Executable file
Binary file not shown.
BIN
environmentex/._.DS_Store
Executable file
BIN
environmentex/._.DS_Store
Executable file
Binary file not shown.
BIN
environmentex/._.gradle
Executable file
BIN
environmentex/._.gradle
Executable file
Binary file not shown.
BIN
environmentex/._build.gradle.kts
Executable file
BIN
environmentex/._build.gradle.kts
Executable file
Binary file not shown.
BIN
environmentex/._gradlew
Executable file
BIN
environmentex/._gradlew
Executable file
Binary file not shown.
BIN
environmentex/._gradlew.bat
Executable file
BIN
environmentex/._gradlew.bat
Executable file
Binary file not shown.
BIN
environmentex/._settings.gradle.kts
Executable file
BIN
environmentex/._settings.gradle.kts
Executable file
Binary file not shown.
BIN
environmentex/._src
Executable file
BIN
environmentex/._src
Executable file
Binary file not shown.
BIN
environmentex/.gradle/._7.4.2
Executable file
BIN
environmentex/.gradle/._7.4.2
Executable file
Binary file not shown.
BIN
environmentex/.gradle/._8.0.2
Executable file
BIN
environmentex/.gradle/._8.0.2
Executable file
Binary file not shown.
BIN
environmentex/.gradle/._buildOutputCleanup
Executable file
BIN
environmentex/.gradle/._buildOutputCleanup
Executable file
Binary file not shown.
BIN
environmentex/.gradle/._caches
Executable file
BIN
environmentex/.gradle/._caches
Executable file
Binary file not shown.
BIN
environmentex/.gradle/._vcs-1
Executable file
BIN
environmentex/.gradle/._vcs-1
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/._checksums
Executable file
BIN
environmentex/.gradle/7.4.2/._checksums
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/._dependencies-accessors
Executable file
BIN
environmentex/.gradle/7.4.2/._dependencies-accessors
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/._executionHistory
Executable file
BIN
environmentex/.gradle/7.4.2/._executionHistory
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/._fileChanges
Executable file
BIN
environmentex/.gradle/7.4.2/._fileChanges
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/._fileHashes
Executable file
BIN
environmentex/.gradle/7.4.2/._fileHashes
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/._gc.properties
Executable file
BIN
environmentex/.gradle/7.4.2/._gc.properties
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/._vcsMetadata
Executable file
BIN
environmentex/.gradle/7.4.2/._vcsMetadata
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/checksums/._checksums.lock
Executable file
BIN
environmentex/.gradle/7.4.2/checksums/._checksums.lock
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/checksums/._md5-checksums.bin
Executable file
BIN
environmentex/.gradle/7.4.2/checksums/._md5-checksums.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/checksums/._sha1-checksums.bin
Executable file
BIN
environmentex/.gradle/7.4.2/checksums/._sha1-checksums.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/checksums/checksums.lock
Executable file
BIN
environmentex/.gradle/7.4.2/checksums/checksums.lock
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/checksums/md5-checksums.bin
Executable file
BIN
environmentex/.gradle/7.4.2/checksums/md5-checksums.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/checksums/sha1-checksums.bin
Executable file
BIN
environmentex/.gradle/7.4.2/checksums/sha1-checksums.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/dependencies-accessors/._dependencies-accessors.lock
Executable file
BIN
environmentex/.gradle/7.4.2/dependencies-accessors/._dependencies-accessors.lock
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/dependencies-accessors/._gc.properties
Executable file
BIN
environmentex/.gradle/7.4.2/dependencies-accessors/._gc.properties
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock
Executable file
BIN
environmentex/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock
Executable file
Binary file not shown.
0
environmentex/.gradle/7.4.2/dependencies-accessors/gc.properties
Executable file
0
environmentex/.gradle/7.4.2/dependencies-accessors/gc.properties
Executable file
BIN
environmentex/.gradle/7.4.2/executionHistory/._executionHistory.lock
Executable file
BIN
environmentex/.gradle/7.4.2/executionHistory/._executionHistory.lock
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/executionHistory/executionHistory.lock
Executable file
BIN
environmentex/.gradle/7.4.2/executionHistory/executionHistory.lock
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/fileChanges/._last-build.bin
Executable file
BIN
environmentex/.gradle/7.4.2/fileChanges/._last-build.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/fileChanges/last-build.bin
Executable file
BIN
environmentex/.gradle/7.4.2/fileChanges/last-build.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/fileHashes/._fileHashes.lock
Executable file
BIN
environmentex/.gradle/7.4.2/fileHashes/._fileHashes.lock
Executable file
Binary file not shown.
BIN
environmentex/.gradle/7.4.2/fileHashes/fileHashes.lock
Executable file
BIN
environmentex/.gradle/7.4.2/fileHashes/fileHashes.lock
Executable file
Binary file not shown.
0
environmentex/.gradle/7.4.2/gc.properties
Executable file
0
environmentex/.gradle/7.4.2/gc.properties
Executable file
BIN
environmentex/.gradle/8.0.2/._checksums
Executable file
BIN
environmentex/.gradle/8.0.2/._checksums
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/._dependencies-accessors
Executable file
BIN
environmentex/.gradle/8.0.2/._dependencies-accessors
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/._fileChanges
Executable file
BIN
environmentex/.gradle/8.0.2/._fileChanges
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/._fileHashes
Executable file
BIN
environmentex/.gradle/8.0.2/._fileHashes
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/._gc.properties
Executable file
BIN
environmentex/.gradle/8.0.2/._gc.properties
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/._vcsMetadata
Executable file
BIN
environmentex/.gradle/8.0.2/._vcsMetadata
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/checksums/._checksums.lock
Executable file
BIN
environmentex/.gradle/8.0.2/checksums/._checksums.lock
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/checksums/._md5-checksums.bin
Executable file
BIN
environmentex/.gradle/8.0.2/checksums/._md5-checksums.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/checksums/._sha1-checksums.bin
Executable file
BIN
environmentex/.gradle/8.0.2/checksums/._sha1-checksums.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/checksums/checksums.lock
Executable file
BIN
environmentex/.gradle/8.0.2/checksums/checksums.lock
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/checksums/md5-checksums.bin
Executable file
BIN
environmentex/.gradle/8.0.2/checksums/md5-checksums.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/checksums/sha1-checksums.bin
Executable file
BIN
environmentex/.gradle/8.0.2/checksums/sha1-checksums.bin
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/dependencies-accessors/._dependencies-accessors.lock
Executable file
BIN
environmentex/.gradle/8.0.2/dependencies-accessors/._dependencies-accessors.lock
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/dependencies-accessors/._gc.properties
Executable file
BIN
environmentex/.gradle/8.0.2/dependencies-accessors/._gc.properties
Executable file
Binary file not shown.
BIN
environmentex/.gradle/8.0.2/dependencies-accessors/dependencies-accessors.lock
Executable file
BIN
environmentex/.gradle/8.0.2/dependencies-accessors/dependencies-accessors.lock
Executable file
Binary file not shown.
0
environmentex/.gradle/8.0.2/dependencies-accessors/gc.properties
Executable file
0
environmentex/.gradle/8.0.2/dependencies-accessors/gc.properties
Executable file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user