Skip to content

Commit

Permalink
Workspace Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
A5005 authored Nov 8, 2021
1 parent c4a5ec3 commit e4ed6da
Show file tree
Hide file tree
Showing 26 changed files with 2,646 additions and 655 deletions.
151 changes: 151 additions & 0 deletions BindItems.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package de.luke.naruto;

import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import de.luke.naruto.commands.Bypass;
import de.luke.naruto.extras.TestDatabase;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

public class BindItems implements Listener {

@EventHandler
public void onPlayerFirstJoin(PlayerJoinEvent event) throws SQLException {
Player p = event.getPlayer();

if (!p.hasPlayedBefore()) {
ItemStack arrow = new ItemStack(Material.ARROW);
ItemMeta arrowim = arrow.getItemMeta();
arrowim.setDisplayName("§f§lKunai");
arrow.setItemMeta(arrowim);

p.getInventory().setItem(8, new ItemStack(arrow));

p.updateInventory();

ItemStack chest = new ItemStack(Material.ENDER_CHEST);
ItemMeta chestim = chest.getItemMeta();
chestim.setDisplayName("§c§lCollection");
chest.setItemMeta(chestim);
p.getInventory().setItem(17, new ItemStack(chest));

p.updateInventory();
Bukkit.broadcastMessage("§bWelcome §a" + p.getName() + " §bto the Server!");

PreparedStatement st = null;

st = TestDatabase.mysql.getConnection().prepareStatement(
"INSERT INTO `Materialnumber`(`uuid`,`sticknumber`,`woodbuttonnumber`,`stonebuttonnumber`,`woodpreasureplatenumber`,`stonepreasureplatenumber`,`feathernumber`,`leathernumber`,`papernumber`,`booknumber`,`stringnumber`,`bonenumber`,`bricknumber`,`netherbricknumber`,`claynumber`,`coalnumber`,`flintnumber`,`gunpowdernumber`,`fireworkstarnumber`,`spidereggnumber`,`glowstonenumber`,`quartznumber`,`magmacreamnumber`,`ironnumber`,`goldnumber`,`prismarineshardnumber`,`prismarinecrystalnumber`,`compassnumber`,`ghasttearnumber`,`blazepowdernumber`,`slimeballnumber`,`eyeofendernumber`,`diamondnumber`,`emeraldnumber`,`bottleofenchantingnumber`,`netherstarnumber`,`endcrystalnumber`) VALUES (\""
+ p.getUniqueId().toString()
+ "\",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)");
st.execute();

st = TestDatabase.mysql.getConnection()
.prepareStatement("INSERT INTO `Arrow`(`uuid`, `number`, `hasblueprint`, `level`) VALUES (\""
+ p.getUniqueId() + "\",0,true,1)");
st.execute();
}

}

@EventHandler
public void onRespawn(PlayerRespawnEvent event) {
Player p = event.getPlayer();
ItemStack arrow = new ItemStack(Material.ARROW);
ItemMeta arrowim = arrow.getItemMeta();
arrowim.setDisplayName("§f§lKunai");
arrow.setItemMeta(arrowim);

p.getInventory().setItem(8, new ItemStack(arrow));

p.updateInventory();

ItemStack chest = new ItemStack(Material.ENDER_CHEST);
ItemMeta chestim = chest.getItemMeta();
chestim.setDisplayName("§c§lCollection");
chest.setItemMeta(chestim);
p.getInventory().setItem(17, new ItemStack(chest));

p.updateInventory();

}

@EventHandler
public void onDrop(PlayerDropItemEvent event) throws SQLException {
Player player = event.getPlayer();
if (Bypass.isBypassed(player.getUniqueId().toString()) == false) {
event.setCancelled(true);
}

}

@EventHandler
public void onInventoryClick(InventoryClickEvent event) throws SQLException {

if (event.getWhoClicked() instanceof Player) {
if (event.getClickedInventory() == null)
return;
if ((event.getCurrentItem().getType() == Material.ENDER_CHEST)) {
Collection.openGUIcommonMaterials((Player) event.getWhoClicked());
event.setCancelled(true);
return;
}

if ((event.getWhoClicked().getOpenInventory().getTopInventory().getName().toString().contains("Material"))
|| (event.getWhoClicked().getOpenInventory().getTopInventory().getName().toString()
.contains("Weapons"))) {

event.setCancelled(true);
}

} else
event.setCancelled(true);

}

@EventHandler
public void onSetAttempt(PlayerInteractEvent event) throws SQLException {
// check if the action is left click or an attempt to break a block AND the
// block is bedrock
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Player player = event.getPlayer();
if (Bypass.isBypassed(player.getUniqueId().toString()) == false) {
event.setCancelled(true);
}
}
}

@EventHandler
public void onBreakAttempt(PlayerInteractEvent event) throws SQLException {
// check if the action is left click or an attempt to break a block AND the
// block is bedrock
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
Player player = event.getPlayer();
if (Bypass.isBypassed(player.getUniqueId().toString()) == false) {
event.setCancelled(true);
}
}
}

// Hunger loss
@EventHandler
public void onFoodLevelChange(FoodLevelChangeEvent event) {
event.setCancelled(true);
}

}
55 changes: 55 additions & 0 deletions Calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package de.luke.naruto;

import java.io.File;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;

public class Calculator implements CommandExecutor {

//Level 1 = 0xp
//Level 2 = 200xp
//Level 3 = 200xp+(3*100)
//Level 4 = 500xp+(400)
//Level 5 = 900xp +(500)



public static int level(int xp) {
int x = 200;
int Durchläufe = 0;
while (!(x > xp)) {
x = x + (Durchläufe + 3) * 100;
Durchläufe++;
}




return (Durchläufe + 1);
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player) {
Player player = (Player) sender;
String playerName = player.getName();
File userdata = new File(Bukkit.getServer().getPluginManager().getPlugin("Naruto").getDataFolder(), File.separator + "PlayerDatabase");
File f = new File(userdata, File.separator + playerName + ".yml");
FileConfiguration playerData = YamlConfiguration.loadConfiguration(f);
sender.sendMessage("§a§lLevel: "+ level(playerData.getInt("xplevel.balance")));




} else sender.sendMessage("§cCommand only for Players!");


return false;
}
}
Loading

0 comments on commit e4ed6da

Please sign in to comment.