[SHARE] Announce dropped item from mob (need specify id of item) (good for epic itens announce works only from mob drops)

package Announce;

import l2.gameserver.Announcements;
import l2.gameserver.listener.actor.player.OnItemPickupListener;
import l2.gameserver.model.Player;
import l2.gameserver.model.actor.listener.PlayerListenerList;
import l2.gameserver.model.items.ItemInstance;
import l2.gameserver.network.l2.components.ChatType;
import l2.gameserver.scripts.Functions;
import l2.gameserver.scripts.ScriptFile;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

public class Announce extends Functions implements ScriptFile, OnItemPickupListener {

private static final List<Integer> itemIds = new ArrayList<>();

@Override
public void onLoad() {
PlayerListenerList.addGlobal(this);
loadItemIds();
System.out.println("Drop announcing script activated");
}

@Override
public void onReload() {}

@Override
public void onShutdown() {
PlayerListenerList.removeGlobal(this);
}

@Override
public void onItemPickup(Player player, ItemInstance itemInstance) {
if (itemIds.contains(itemInstance.getItemId()) && itemInstance.getLastDropTime() == 0) {
String playerName = player.getName();
String itemName = itemInstance.getName();
String message = String.format("PT >Atencao< : %s acabou de dropar [%s]", playerName, itemName);
String message1 = String.format("EN >Attention< : %s just dropped [%s]", playerName, itemName);


System.out.println(message);
System.out.println(message1);
Announcements.getInstance().announceToAll(message, ChatType.SHOUT);
Announcements.getInstance().announceToAll(message1, ChatType.SHOUT);
}
}

private void loadItemIds() {
try (BufferedReader reader = new BufferedReader(new FileReader(new File("config/itemids.properties")))) {
String line;
while ((line = reader.readLine()) != null) {
int itemId = Integer.parseInt(line.trim());
itemIds.add(itemId);
System.out.println("Item IDs loaded successfully - Drop Announcing System");
}
} catch (IOException e) {
System.err.println("Error loading item IDs from file config/itemids.properties: " + e.getMessage());
}
}
}
 
package Announce;

import l2.gameserver.Announcements;
import l2.gameserver.listener.actor.player.OnItemPickupListener;
import l2.gameserver.model.Player;
import l2.gameserver.model.actor.listener.PlayerListenerList;
import l2.gameserver.model.items.ItemInstance;
import l2.gameserver.network.l2.components.ChatType;
import l2.gameserver.scripts.Functions;
import l2.gameserver.scripts.ScriptFile;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

public class Announce extends Functions implements ScriptFile, OnItemPickupListener {

private static final List<Integer> itemIds = new ArrayList<>();

@Override
public void onLoad() {
PlayerListenerList.addGlobal(this);
loadItemIds();
System.out.println("Drop announcing script activated");
}

@Override
public void onReload() {}

@Override
public void onShutdown() {
PlayerListenerList.removeGlobal(this);
}

@Override
public void onItemPickup(Player player, ItemInstance itemInstance) {
if (itemIds.contains(itemInstance.getItemId()) && itemInstance.getLastDropTime() == 0) {
String playerName = player.getName();
String itemName = itemInstance.getName();
String message = String.format("PT >Atencao< : %s acabou de dropar [%s]", playerName, itemName);
String message1 = String.format("EN >Attention< : %s just dropped [%s]", playerName, itemName);


System.out.println(message);
System.out.println(message1);
Announcements.getInstance().announceToAll(message, ChatType.SHOUT);
Announcements.getInstance().announceToAll(message1, ChatType.SHOUT);
}
}

private void loadItemIds() {
try (BufferedReader reader = new BufferedReader(new FileReader(new File("config/itemids.properties")))) {
String line;
while ((line = reader.readLine()) != null) {
int itemId = Integer.parseInt(line.trim());
itemIds.add(itemId);
System.out.println("Item IDs loaded successfully - Drop Announcing System");
}
} catch (IOException e) {
System.err.println("Error loading item IDs from file config/itemids.properties: " + e.getMessage());
}
}
}
this is the code? honestly i don't get it.
the post says SHARE and now the owner is SELLING it.
 
I'm not the owner, I simply fixed the code that was posted there and posted it again for anyone interested in using it. I apologize to the owner for doing this, but until then I know he had stopped working on their project.
 
If you look closely, you can get the code and write it again and use it. That's what I did. This is the reason for the EXTRA JAVA. WITH THIS, YOU JUST NEED TO CREATE THE FILE item

and I'm not asking for anything in return, not money or anything, quite the opposite, I feel offended by the comment.

your money and what do I lose my knowledge? Nothing? I simply wanted to help other people who came looking for and could not find the code anymore, that's it
 
Back
Top