Minecraft Plugin setMotd() [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I was looking for some time how to use setMotd() function, but I can't find anything useful. I've found ServerListPingEvent http://www.javaminecraft.com/bukkitapi/org/bukkit/event/server/ServerListPingEvent.html but I've got no idea how to use it... Maybe You could help me?

To listen to this event and, as a response, change the motd, you need a Listener. Define a class implementing Listener (let's say FooListener) with the following method declaration:
#EventHandler
public void onServerListPingEvent(ServerListPingEvent event) {
event.setMotd("Some MOTD");
}
You then need to register this listener in one of your plugin class's onLoad() or onEnable() methods. Do this like so:
#Override
public void onLoad() { // or onEnable()
// other stuff
getServer().getPluginManager().registerEvents(new FooListener(), this);
}
If you want to colour your MOTD, look it up. You have to use the section sign (ยง).

Related

How to change a color of string/text in UI application build in java swing? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 months ago.
Improve this question
I have a string/text that I want to show on UI made with java swing. I need to color that text. I was using HTML to color my string and it was working fine till now. But now we have to stop using HTML for coloring string for some reason. I am looking for other alternatives.
My existing approach was something like this:
public class dummy{
public static void main(String []args){
System.out.println("<html><font color=red>"+"This is my simple text" +"</font></html>");
}
}
I have checked for JTREE Render, but that's for tree node coloring and that's not suiting my scenario. Any other suggestion is most welcomed.
This may help:
JButton b = new JButton("<html><center><b><u>D</u>isable</b><br>"
+ "<font color=#ffffdd>middle button</font>",
leftButtonIcon);
b.setForeground(Color.RED);
b.setBackground(Color.WHITE);
Set color using setForeground and setBackground methods
How to Use HTML in Swing Components

Java Enable/Disable Button [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm creating a game that uses buttons. I want to disable a button once it's been selected, so that it cannot again until the game has restarted, but I'm having trouble achieving this. Could some let me know how to go about doing this?
public void actionPerformed(ActionEvent e) {
if (q==2) {
label2.setText("Correct!"); }
else {
label2.setText("Wrong!!");
}}
You can get the source of the event from the ActionEvent with getSource. Then cast it to the correct type, and disable it with setEnabled
Here's an example, assuming you're using JButton
public void actionPerformed(ActionEvent e) {
if (q==2) {
label2.setText("Correct!");
} else {
label2.setText("Wrong!!");
}
if(e.getSource() instanceof JButton) {
((JButton)e.getSource()).setEnabled(false);
}
}
Call button.setEnabled(false) to disable it, and button.setEnabled(true) to reinstate it.
What's the trouble? I trust you've taken a look at the JButton documentation (assuming you're using JButtons). Using this function will allow you to enable/disable buttons.
JButton.setEnabled(boolean)

How do I take 25 screenshots of my screen every second [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
The reason I need this is cause I'm creating a free screen recorder named fraser and I really need to be able to make it have a FrameRate. Can someone please tell me how do I make it take 25 screenshots every second?
You could use java.awt.Robot; it has a method called createScreenCapture(Rectangle screenRect). For the delay between the screenshots, use for example Thread.sleep(long millis).
The code for this program is up to you to write, though.
Java introduced a screen grabber that may be of some use to you. You can change how many shots it take in time intervals. Check it out Here
See in this direction:
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3);
Then you can define MyClass class:
class MyClass implements Runnable {
Robot robot = new Robot();
#Override
public void run() {
BufferedImage image = robot.createScreenCapture(...);
}
}
And then you can do this:
scheduler.scheduleAtFixedRate(new MyClass(), 1, 1, TimeUnit.SECONDS);

I want to provide a functionality to our users to printscreen and then use Ctrl+V to add image as attachment without saving image anywhere [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a GWT app and i want to provide a functionality to users simply press printscreen and then on pressing Ctrl+V it should automatically get attached as an image like gmail,skype etc.
There is an event for pasting:
com.google.gwt.user.client.Event.ONPASTE
I use this but only for pasting text (user must press Ctrl+V or right-click>Paste). I guess there may be a way for you to use this.
To capture the event, I sink it to my Widget first:
sinkEvents(Event.ONPASTE | Event.ONKEYPRESS | Event.ONKEYDOWN | Event.ONFOCUS);
Then, I implement onBrowserEvent(Event):
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
switch (event.getTypeInt()) {
case Event.ONPASTE: paste(event);
}
}
Hope you can find a way to adapt this for images.

MouseClicked Dilemma [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Is it possible to create a if statement questioning if a user has clicked an image using the java method mouseClicked? If so how?
This is what I was thinking would be correct
public void mouseClicked(parameters of image){
//Sample Code
}
To be able to view an image, it must be loaded and placed on a Component (JPanel, JLabel, etc.) right? I'm assuming here since you made no mention of custom painting and provided no code. So just add a MouseListener to whichever Component has the image:
JLabel label = new JLabel();
// add the image to the label, then:
label.addMouseListener(new MouseAdapter()
{
#Override
public void mouseClicked(MouseEvent e)
{
System.out.println("Image was clicked!");
}
});

Categories