Diff
checker
Text
Text
Bilder
Dokumente
Excel
Ordner
Legal
Enterprise
Desktop-App
Preise
Einloggen
Diffchecker Desktop herunterladen
Texte vergleichen
Finde den Unterschied zwischen zwei Textdateien
Werkzeuge
Verlauf
Live-Editor
Leerzeichen ausblenden
Gleiches ausblenden
Zeilenumbruch aus
Ansicht
Zweispaltig
Einspaltig
Vergleichsgenauigkeit
Intelligent
Wort
Zeichen
Textstile
Darstellung ändern
Syntaxhervorhebung
Syntax auswählen
Ignorieren
Text umwandeln
Zur ersten Änderung
Eingabe bearbeiten
Diffchecker Desktop
Der sicherste Weg, Diffchecker zu nutzen. Hol dir die Desktop-App: Deine Diffs verlassen nie deinen Computer!
Desktop holen
Untitled diff
Erstellt
vor 9 Jahren
Diff läuft nie ab
Löschen
Exportieren
Teilen
Erklären
55 Entfernungen
Zeilen
Gesamt
Entfernt
Zeichen
Gesamt
Entfernt
Um diese Funktion weiterhin zu nutzen, aktualisiere auf
Diff
checker
Pro
Preise anzeigen
73 Zeilen
Kopieren
78 Hinzufügungen
Zeilen
Gesamt
Hinzugefügt
Zeichen
Gesamt
Hinzugefügt
Um diese Funktion weiterhin zu nutzen, aktualisiere auf
Diff
checker
Pro
Preise anzeigen
106 Zeilen
Kopieren
public class Main extends JavaPlugin implements Listener {
public class Main extends JavaPlugin implements Listener {
Kopieren
Kopiert
Kopieren
Kopiert
private ItemStack starterDChest;
private HashMap<UUID, Integer> cooldown = new HashMap<UUID, Integer>();
public void onEnable() {
public void onEnable() {
Bukkit.getServer().getPluginManager().registerEvents(this, this);
Bukkit.getServer().getPluginManager().registerEvents(this, this);
Kopieren
Kopiert
Kopieren
Kopiert
starterDChest = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemMeta dchestmeta = starterDChest.getItemMeta();
ArrayList<String> lore = new ArrayList<String>(); //Moved this down here because why create it if they can't even use the command?
dchestmeta.setDisplayName(ChatColor.AQUA + ChatColor.BOLD.toString() + "Starter!");
lore.add(ChatColor.BLUE + ChatColor.ITALIC.toString() + "Gives you the Starter Gear!!");
lore.add(""); //Will probably have more success with empty Strings as placeholders rather than null String objects
lore.add("");
lore.add(ChatColor.WHITE + ChatColor.BOLD.toString() + "--" +
ChatColor.RED + ChatColor.BOLD.toString() + "JUST LEFT/RIGHT CLICK"
+ ChatColor.WHITE + ChatColor.BOLD.toString() + "--" );
dchestmeta.setLore(lore);
starterDChest.setItemMeta(dchestmeta);
new BukkitRunnable() { //This is gonna be our global loop so that we don't have to create a task for every person that uses the kit
@Override
public void run() {
for(Player all : getServer().getOnlinePlayers()) {
if(!cooldown.containsKey(all.getUniqueId())) continue; //Not relevant; not in cooldown list, skip them
if(cooldown.get(all.getUniqueId()) <= 0) {
//Done cooling down
cooldown.remove(all.getUniqueId());
all.sendMessage(ChatColor.GREEN + "You can use kit again!!");
}
else {
//Still cooling down
int timeLeftSec = cooldown.put(all.getUniqueId(), cooldown.get(all.getUniqueId()) - 1); //Subtracts a second from their wait time
if(timeLeftSec % 60 == 0) {
all.sendMessage(ChatColor.RED + "You have " + (timeLeftSec / 60) + ((timeLeftSec / 60) == 1 : "minute" : "minutes") + " left for Starter kit!!");
}
}
}
}
}, this, 0L, 1*20L); //Run every second with a 0 tick delay
}
}
Kopieren
Kopiert
Kopieren
Kopiert
ArrayList<Player> cooldown = new ArrayList<Player>();
@Override
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] arg) {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] arg) {
Kopieren
Kopiert
Kopieren
Kopiert
if (
label
.equalsIgnoreCase("k")) {
if (
cmd.getName()
.equalsIgnoreCase("k")) {
//Backwards compatible with aliases entry in the plugin.yml
ArrayList<String> lore = new ArrayList<String>();
final Player p = (Player) sender;
if (!(sender instanceof Player)) {
if (!(sender instanceof Player)) {
Kopieren
Kopiert
Kopieren
Kopiert
p
.sendMessage("You need to be a Player to do this Command!");
sender
.sendMessage("You need to be a Player to do this Command!");
return true; //This tells the method to stop here and go back, ignoring underneath parts.
}
}
Kopieren
Kopiert
Kopieren
Kopiert
Player p = (Player) sender; //Now we can safely do this, earlier we were doing it before we were sure it was a player, good try though.
ItemStack dchest = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemMeta dchestmeta = dchest.getItemMeta();
dchestmeta.setDisplayName(ChatColor.AQUA + ChatColor.BOLD.toString() + "Starter!");
lore.add(ChatColor.BLUE + ChatColor.ITALIC.toString() + "Gives you the Starter Gear!!");
lore.add(null);
lore.add(null);
lore.add(ChatColor.WHITE + ChatColor.BOLD.toString() + "--" +
ChatColor.RED + ChatColor.BOLD.toString() + "JUST LEFT/RIGHT CLICK"
+ ChatColor.WHITE + ChatColor.BOLD.toString() + "--" );
dchestmeta.setLore(lore);
dchest.setItemMeta(dchestmeta);
Inventory inv = Bukkit.createInventory(null, 27, ChatColor.RED + ChatColor.BOLD.toString() + "Kits");
Inventory inv = Bukkit.createInventory(null, 27, ChatColor.RED + ChatColor.BOLD.toString() + "Kits");
Kopieren
Kopiert
Kopieren
Kopiert
inv.setItem(0,
dchest);
inv.setItem(0,
starterDChest);
p.openInventory(inv);
p.openInventory(inv);
}
}
return true;
return true;
}
}
@EventHandler
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
public void onInventoryClick(InventoryClickEvent e) {
Kopieren
Kopiert
Kopieren
Kopiert
if (
e.getInventory().getTitle().equals(ChatColor.RED + ChatColor.BOLD.toString() + "Kits")) {
if (
!
e.getInventory().getTitle().equals(ChatColor.RED + ChatColor.BOLD.toString() + "Kits")) {
int time = 20*25;
return; //Forget about this occurrence of the event then, we aren't interested
ItemStack ironh = new ItemStack(Material.IRON_HELMET);
}
ironh.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
//Because of the above if statement, we know it's the inventory we're looking for. This removes all that excessive indentation from before
ItemStack ironc = new ItemStack(Material.IRON_CHESTPLATE);
//Time no longer needed since we created a global loop
ironc.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
ItemStack ironh = new ItemStack(Material.IRON_HELMET);
ItemStack ironl = new ItemStack(Material.IRON_LEGGINGS);
ironh.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
ironl.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
ItemStack ironc = new ItemStack(Material.IRON_CHESTPLATE);
ItemStack ironb = new ItemStack(Material.IRON_BOOTS);
ironc.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
ironb.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
ItemStack ironl = new ItemStack(Material.IRON_LEGGINGS);
ironb.addEnchantment(Enchantment.PROTECTION_FALL, 1);
ironl.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
ItemStack irons = new ItemStack(Material.IRON_SWORD);
ItemStack ironb = new ItemStack(Material.IRON_BOOTS);
irons.addEnchantment(Enchantment.DAMAGE_ALL, 1);
ironb.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
irons.addEnchantment(Enchantment.DURABILITY, 3);
ironb.addEnchantment(Enchantment.PROTECTION_FALL, 1);
ItemStack irons = new ItemStack(Material.IRON_SWORD);
if (cooldown.contains(
e.getWhoClicked()
)) {
irons.addEnchantment(Enchantment.DAMAGE_ALL, 1);
e.getWhoClicked().sendMessage("until next kit!");
irons.addEnchantment(Enchantment.DURABILITY, 3);
e.setCancelled(true);
Player p = (Player)
e.getWhoClicked()
;
} else if (e.getSlot() == 0) {
if (cooldown.containsKey(p.getUniqueId())) {
e.setCancelled(true);
int minutes = (int) TimeUnit.SECONDS.toMinutes(cooldown.get(p.getUniqueId()));
e.getWhoClicked().getInventory().addItem(ironh, ironc, ironl, ironb, irons);
String cdMessage = "";
e.getWhoClicked().closeInventory();
if(minutes == 0) {
cooldown.add((Player) e.getWhoClicked());
int seconds =
cooldown.
get(p.getUniqueId
());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
cdMessage += (seconds == 1 ? "second" : "seconds") + " left";
public void run() {
}
cooldown.
remove(e.getWhoClicked
());
else {
e.getWhoClicked().sendMessage(ChatColor.RED + "You can use kit Starter again!!");
cdMessage += (minutes == 1 ? "minute" : "minutes") + " left";
}
}, time);
e.getWhoClicked().sendMessage(ChatColor.RED + "Given Starter!");
}
}
Kopieren
Kopiert
Kopieren
Kopiert
p.sendMessage(cdMessage + " until next kit!");
e.setCancelled(true);
return;
}
//They aren't in cooldown due to the return in the cooldown if-statement
if(e.getCurrentItem() == null || e.getCurrentItem().getType().equals(Material.AIR)) {
return;
}
if(e.getCurrentItem().equals(starterDChest)) { //if clicked item (current, clicked, etc) is equal to the starter diamond chest kit item
e.setCancelled(true);
p.getInventory().addItem(ironh, ironc, ironl, ironb, irons);
p.closeInventory();
cooldown.put(p.getUniqueId(), 25); //25 seconds for the cooldown!
p.sendMessage(ChatColor.RED + "Given Starter!");
return;
}
}
}
}
}
}
Gespeicherte Diffs
Originaltext
Datei öffnen
public class Main extends JavaPlugin implements Listener { public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(this, this); } ArrayList<Player> cooldown = new ArrayList<Player>(); @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] arg) { if (label.equalsIgnoreCase("k")) { ArrayList<String> lore = new ArrayList<String>(); final Player p = (Player) sender; if (!(sender instanceof Player)) { p.sendMessage("You need to be a Player to do this Command!"); } ItemStack dchest = new ItemStack(Material.DIAMOND_CHESTPLATE); ItemMeta dchestmeta = dchest.getItemMeta(); dchestmeta.setDisplayName(ChatColor.AQUA + ChatColor.BOLD.toString() + "Starter!"); lore.add(ChatColor.BLUE + ChatColor.ITALIC.toString() + "Gives you the Starter Gear!!"); lore.add(null); lore.add(null); lore.add(ChatColor.WHITE + ChatColor.BOLD.toString() + "--" + ChatColor.RED + ChatColor.BOLD.toString() + "JUST LEFT/RIGHT CLICK" + ChatColor.WHITE + ChatColor.BOLD.toString() + "--" ); dchestmeta.setLore(lore); dchest.setItemMeta(dchestmeta); Inventory inv = Bukkit.createInventory(null, 27, ChatColor.RED + ChatColor.BOLD.toString() + "Kits"); inv.setItem(0, dchest); p.openInventory(inv); } return true; } @EventHandler public void onInventoryClick(InventoryClickEvent e) { if (e.getInventory().getTitle().equals(ChatColor.RED + ChatColor.BOLD.toString() + "Kits")) { int time = 20*25; ItemStack ironh = new ItemStack(Material.IRON_HELMET); ironh.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1); ItemStack ironc = new ItemStack(Material.IRON_CHESTPLATE); ironc.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1); ItemStack ironl = new ItemStack(Material.IRON_LEGGINGS); ironl.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1); ItemStack ironb = new ItemStack(Material.IRON_BOOTS); ironb.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1); ironb.addEnchantment(Enchantment.PROTECTION_FALL, 1); ItemStack irons = new ItemStack(Material.IRON_SWORD); irons.addEnchantment(Enchantment.DAMAGE_ALL, 1); irons.addEnchantment(Enchantment.DURABILITY, 3); if (cooldown.contains(e.getWhoClicked())) { e.getWhoClicked().sendMessage("until next kit!"); e.setCancelled(true); } else if (e.getSlot() == 0) { e.setCancelled(true); e.getWhoClicked().getInventory().addItem(ironh, ironc, ironl, ironb, irons); e.getWhoClicked().closeInventory(); cooldown.add((Player) e.getWhoClicked()); Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { cooldown.remove(e.getWhoClicked()); e.getWhoClicked().sendMessage(ChatColor.RED + "You can use kit Starter again!!"); } }, time); e.getWhoClicked().sendMessage(ChatColor.RED + "Given Starter!"); } } } }
Bearbeitung
Datei öffnen
public class Main extends JavaPlugin implements Listener { private ItemStack starterDChest; private HashMap<UUID, Integer> cooldown = new HashMap<UUID, Integer>(); public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(this, this); starterDChest = new ItemStack(Material.DIAMOND_CHESTPLATE); ItemMeta dchestmeta = starterDChest.getItemMeta(); ArrayList<String> lore = new ArrayList<String>(); //Moved this down here because why create it if they can't even use the command? dchestmeta.setDisplayName(ChatColor.AQUA + ChatColor.BOLD.toString() + "Starter!"); lore.add(ChatColor.BLUE + ChatColor.ITALIC.toString() + "Gives you the Starter Gear!!"); lore.add(""); //Will probably have more success with empty Strings as placeholders rather than null String objects lore.add(""); lore.add(ChatColor.WHITE + ChatColor.BOLD.toString() + "--" + ChatColor.RED + ChatColor.BOLD.toString() + "JUST LEFT/RIGHT CLICK" + ChatColor.WHITE + ChatColor.BOLD.toString() + "--" ); dchestmeta.setLore(lore); starterDChest.setItemMeta(dchestmeta); new BukkitRunnable() { //This is gonna be our global loop so that we don't have to create a task for every person that uses the kit @Override public void run() { for(Player all : getServer().getOnlinePlayers()) { if(!cooldown.containsKey(all.getUniqueId())) continue; //Not relevant; not in cooldown list, skip them if(cooldown.get(all.getUniqueId()) <= 0) { //Done cooling down cooldown.remove(all.getUniqueId()); all.sendMessage(ChatColor.GREEN + "You can use kit again!!"); } else { //Still cooling down int timeLeftSec = cooldown.put(all.getUniqueId(), cooldown.get(all.getUniqueId()) - 1); //Subtracts a second from their wait time if(timeLeftSec % 60 == 0) { all.sendMessage(ChatColor.RED + "You have " + (timeLeftSec / 60) + ((timeLeftSec / 60) == 1 : "minute" : "minutes") + " left for Starter kit!!"); } } } } }, this, 0L, 1*20L); //Run every second with a 0 tick delay } @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] arg) { if (cmd.getName().equalsIgnoreCase("k")) { //Backwards compatible with aliases entry in the plugin.yml if (!(sender instanceof Player)) { sender.sendMessage("You need to be a Player to do this Command!"); return true; //This tells the method to stop here and go back, ignoring underneath parts. } Player p = (Player) sender; //Now we can safely do this, earlier we were doing it before we were sure it was a player, good try though. Inventory inv = Bukkit.createInventory(null, 27, ChatColor.RED + ChatColor.BOLD.toString() + "Kits"); inv.setItem(0, starterDChest); p.openInventory(inv); } return true; } @EventHandler public void onInventoryClick(InventoryClickEvent e) { if (!e.getInventory().getTitle().equals(ChatColor.RED + ChatColor.BOLD.toString() + "Kits")) { return; //Forget about this occurrence of the event then, we aren't interested } //Because of the above if statement, we know it's the inventory we're looking for. This removes all that excessive indentation from before //Time no longer needed since we created a global loop ItemStack ironh = new ItemStack(Material.IRON_HELMET); ironh.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1); ItemStack ironc = new ItemStack(Material.IRON_CHESTPLATE); ironc.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1); ItemStack ironl = new ItemStack(Material.IRON_LEGGINGS); ironl.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1); ItemStack ironb = new ItemStack(Material.IRON_BOOTS); ironb.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1); ironb.addEnchantment(Enchantment.PROTECTION_FALL, 1); ItemStack irons = new ItemStack(Material.IRON_SWORD); irons.addEnchantment(Enchantment.DAMAGE_ALL, 1); irons.addEnchantment(Enchantment.DURABILITY, 3); Player p = (Player) e.getWhoClicked(); if (cooldown.containsKey(p.getUniqueId())) { int minutes = (int) TimeUnit.SECONDS.toMinutes(cooldown.get(p.getUniqueId())); String cdMessage = ""; if(minutes == 0) { int seconds = cooldown.get(p.getUniqueId()); cdMessage += (seconds == 1 ? "second" : "seconds") + " left"; } else { cdMessage += (minutes == 1 ? "minute" : "minutes") + " left"; } p.sendMessage(cdMessage + " until next kit!"); e.setCancelled(true); return; } //They aren't in cooldown due to the return in the cooldown if-statement if(e.getCurrentItem() == null || e.getCurrentItem().getType().equals(Material.AIR)) { return; } if(e.getCurrentItem().equals(starterDChest)) { //if clicked item (current, clicked, etc) is equal to the starter diamond chest kit item e.setCancelled(true); p.getInventory().addItem(ironh, ironc, ironl, ironb, irons); p.closeInventory(); cooldown.put(p.getUniqueId(), 25); //25 seconds for the cooldown! p.sendMessage(ChatColor.RED + "Given Starter!"); return; } } }
Unterschied finden