我有零理由相信这是可能的,但我正在努力恢复我再次提问的能力,考虑到我现在可以做出贡献(计算机科学专业四年级,从事软件工程工作),与当时相比在我真正了解 Java 之前,我还是一名高中生,试图玩弄我的世界模组。
这是最初不起作用的代码,并触发了我决定提出这个问题。
/**
*
*/
package net.halalaboos.huzuni.console.commands;
import net.halalaboos.huzuni.Huzuni;
import net.halalaboos.huzuni.client.notifications.Notification;
import net.halalaboos.huzuni.console.Command;
import net.halalaboos.lib.io.FileUtils;
import net.minecraft.src.GuiPlayerInfo;
import net.minecraft.src.StringUtils;
import twitter4j.*;
import twitter4j.conf.ConfigurationBuilder;
import twitter4j.TwitterException;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class TwitterAlerts implements Command {
public Status tweet;
public String tweetalert;
public ConfigurationBuilder cb = new ConfigurationBuilder();
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
TwitterAlerts object = new TwitterAlerts();
TwitterAlerts()
{
setkey();
checkstatus();
}
public void setkey()
{
setkey();
cb.setDebugEnabled(true);
cb.setOAuthConsumerKey("5c8ZcMgQihdS5kzGun9iSw");
cb.setOAuthConsumerSecret("aRUUbQnDu5yAjmdI23LdjRu6vDtPWaKhc6dFVklne0");
}
List<String> twitters = new ArrayList<String>();
List<String> pasttweets = new ArrayList<String>();
/**
* @see net.halalaboos.huzuni.console.Command#getAliases()
*/
@Override
public String[] getAliases() {
return new String[] {"twitteralerts", "tfollow"};
}
/**
* @see net.halalaboos.huzuni.console.Command#getHelp()
*/
@Override
public String[] getHelp() {
return new String[] {"Do /twitteralerts <name of tweeter> to be alerted of new tweets!"};
}
/**
* @see net.halalaboos.huzuni.console.Command#getDescription()
*/
@Override
public String getDescription() {
return "In game alerts of new tweets on followed accounts.";
}
/**
* @see net.halalaboos.huzuni.console.Command#run(java.lang.String, java.lang.String[])
*/
@Override
public void run(String input, String[] args) {
twitters.add(input);
}
public void checkstatus()
{
while(twitters != null)
{
try {
for(int i=0;i<twitters.size();i++)
{
tweet = twitter.getUserTimeline(twitters.get(i)).get(0);
if (pasttweets.contains(tweet.getText()))
{
}
else
{
Huzuni.notificationManager.add(new Notification("Tweet Retrieved", tweet.getText()));
pasttweets.add(tweet.getText());
}
}
} catch (TwitterException e) {
e.printStackTrace();
}
}
}
}