id
int64 1
194k
| buggy
stringlengths 23
37.5k
| fixed
stringlengths 6
37.4k
|
---|---|---|
1,201 |
import de.vanita5.twittnuker.receiver.NotificationReceiver;
import de.vanita5.twittnuker.service.LengthyOperationsService;
import de.vanita5.twittnuker.util.ActivityTracker;
import de.vanita5.twittnuker.util.AsyncTwitterWrapper;
import de.vanita5.twittnuker.util.DataStoreFunctionsKt;
<BUG>import de.vanita5.twittnuker.util.DataStoreUtils;
import de.vanita5.twittnuker.util.ImagePreloader;</BUG>
import de.vanita5.twittnuker.util.InternalTwitterContentUtils;
import de.vanita5.twittnuker.util.JsonSerializer;
import de.vanita5.twittnuker.util.NotificationManagerWrapper;
|
import de.vanita5.twittnuker.receiver.NotificationReceiver;
import de.vanita5.twittnuker.service.LengthyOperationsService;
import de.vanita5.twittnuker.util.ActivityTracker;
import de.vanita5.twittnuker.util.AsyncTwitterWrapper;
import de.vanita5.twittnuker.util.DataStoreFunctionsKt;
import de.vanita5.twittnuker.util.DataStoreUtils;
import de.vanita5.twittnuker.util.DebugLog;
import de.vanita5.twittnuker.util.ImagePreloader;
import de.vanita5.twittnuker.util.InternalTwitterContentUtils;
import de.vanita5.twittnuker.util.JsonSerializer;
import de.vanita5.twittnuker.util.NotificationManagerWrapper;
|
1,202 |
final List<InetAddress> addresses = mDns.lookup(host);
for (InetAddress address : addresses) {
c.addRow(new String[]{host, address.getHostAddress()});
}
} catch (final IOException ignore) {
<BUG>if (BuildConfig.DEBUG) {
Log.w(LOGTAG, ignore);
}</BUG>
}
|
final List<InetAddress> addresses = mDns.lookup(host);
for (InetAddress address : addresses) {
c.addRow(new String[]{host, address.getHostAddress()});
}
} catch (final IOException ignore) {
DebugLog.w(LOGTAG, null, ignore);
}
|
1,203 |
import de.vanita5.twittnuker.annotation.CustomTabType;
import de.vanita5.twittnuker.library.MicroBlog;
import de.vanita5.twittnuker.library.MicroBlogException;
import de.vanita5.twittnuker.library.twitter.model.RateLimitStatus;
import de.vanita5.twittnuker.library.twitter.model.Status;
<BUG>import de.vanita5.twittnuker.fragment.AbsStatusesFragment;
import org.mariotaku.sqliteqb.library.AllColumns;</BUG>
import org.mariotaku.sqliteqb.library.Columns;
import org.mariotaku.sqliteqb.library.Columns.Column;
import org.mariotaku.sqliteqb.library.Expression;
|
import de.vanita5.twittnuker.annotation.CustomTabType;
import de.vanita5.twittnuker.library.MicroBlog;
import de.vanita5.twittnuker.library.MicroBlogException;
import de.vanita5.twittnuker.library.twitter.model.RateLimitStatus;
import de.vanita5.twittnuker.library.twitter.model.Status;
import de.vanita5.twittnuker.fragment.AbsStatusesFragment;
import org.mariotaku.pickncrop.library.PNCUtils;
import org.mariotaku.sqliteqb.library.AllColumns;
import org.mariotaku.sqliteqb.library.Columns;
import org.mariotaku.sqliteqb.library.Columns.Column;
import org.mariotaku.sqliteqb.library.Expression;
|
1,204 |
context.getApplicationContext().sendBroadcast(intent);
}
}
@Nullable
public static Location getCachedLocation(Context context) {
<BUG>if (BuildConfig.DEBUG) {
Log.v(LOGTAG, "Fetching cached location", new Exception());
}</BUG>
Location location = null;
|
context.getApplicationContext().sendBroadcast(intent);
}
}
@Nullable
public static Location getCachedLocation(Context context) {
DebugLog.v(LOGTAG, "Fetching cached location", new Exception());
Location location = null;
|
1,205 |
FileBody fileBody = null;
try {
fileBody = getFileBody(context, imageUri);
twitter.updateProfileBannerImage(fileBody);
} finally {
<BUG>Utils.closeSilently(fileBody);
if (deleteImage && "file".equals(imageUri.getScheme())) {
final File file = new File(imageUri.getPath());
if (!file.delete()) {
Log.w(LOGTAG, String.format("Unable to delete %s", file));
}</BUG>
}
|
FileBody fileBody = null;
try {
fileBody = getFileBody(context, imageUri);
twitter.updateProfileBannerImage(fileBody);
} finally {
Utils.closeSilently(fileBody);
if (deleteImage) {
Utils.deleteMedia(context, imageUri);
|
1,206 |
FileBody fileBody = null;
try {
fileBody = getFileBody(context, imageUri);
twitter.updateProfileBackgroundImage(fileBody, tile);
} finally {
<BUG>Utils.closeSilently(fileBody);
if (deleteImage && "file".equals(imageUri.getScheme())) {
final File file = new File(imageUri.getPath());
if (!file.delete()) {
Log.w(LOGTAG, String.format("Unable to delete %s", file));
}</BUG>
}
|
FileBody fileBody = null;
try {
fileBody = getFileBody(context, imageUri);
twitter.updateProfileBannerImage(fileBody);
} finally {
Utils.closeSilently(fileBody);
if (deleteImage) {
Utils.deleteMedia(context, imageUri);
|
1,207 |
FileBody fileBody = null;
try {
fileBody = getFileBody(context, imageUri);
return twitter.updateProfileImage(fileBody);
} finally {
<BUG>Utils.closeSilently(fileBody);
if (deleteImage && "file".equals(imageUri.getScheme())) {
final File file = new File(imageUri.getPath());
if (!file.delete()) {
Log.w(LOGTAG, String.format("Unable to delete %s", file));
}</BUG>
}
|
FileBody fileBody = null;
try {
fileBody = getFileBody(context, imageUri);
twitter.updateProfileBannerImage(fileBody);
} finally {
Utils.closeSilently(fileBody);
if (deleteImage) {
Utils.deleteMedia(context, imageUri);
|
1,208 |
import java.util.List;
import java.util.Map.Entry;
import javax.inject.Singleton;
import okhttp3.Dns;
@Singleton
<BUG>public class TwidereDns implements Constants, Dns {
</BUG>
private static final String RESOLVER_LOGTAG = "TwittnukerDns";
private final SharedPreferences mHostMapping;
private final SharedPreferencesWrapper mPreferences;
|
import java.util.List;
import java.util.Map.Entry;
import javax.inject.Singleton;
import okhttp3.Dns;
@Singleton
public class TwidereDns implements Dns, Constants {
private static final String RESOLVER_LOGTAG = "TwittnukerDns";
private final SharedPreferences mHostMapping;
private final SharedPreferencesWrapper mPreferences;
|
1,209 |
private List<InetAddress> resolveInternal(final String originalHost, final String host, final int depth,
final boolean useResolver) throws IOException, SecurityException {
final TimingLogger logger = new TimingLogger(RESOLVER_LOGTAG, "resolve");
final List<InetAddress> fromAddressString = fromAddressString(originalHost, host);
if (fromAddressString != null) {
<BUG>if (BuildConfig.DEBUG) {</BUG>
addLogSplit(logger, host, "valid ip address", depth);
dumpLog(logger, fromAddressString);
<BUG>}</BUG>
return fromAddressString;
|
private List<InetAddress> resolveInternal(final String originalHost, final String host, final int depth,
final boolean useResolver) throws IOException, SecurityException {
final TimingLogger logger = new TimingLogger(RESOLVER_LOGTAG, "resolve");
final List<InetAddress> fromAddressString = fromAddressString(originalHost, host);
if (fromAddressString != null) {
addLogSplit(logger, host, "valid ip address", depth);
dumpLog(logger, fromAddressString);
return fromAddressString;
|
1,210 |
if (useResolver) {
addLogSplit(logger, host, "start /etc/hosts resolve", depth);
final List<InetAddress> fromSystemHosts = fromSystemHosts(host);
addLogSplit(logger, host, "end /etc/hosts resolve", depth);
if (fromSystemHosts != null) {
<BUG>if (BuildConfig.DEBUG) {</BUG>
dumpLog(logger, fromSystemHosts);
<BUG>}</BUG>
return fromSystemHosts;
}
|
if (useResolver) {
addLogSplit(logger, host, "start /etc/hosts resolve", depth);
final List<InetAddress> fromSystemHosts = fromSystemHosts(host);
addLogSplit(logger, host, "end /etc/hosts resolve", depth);
if (fromSystemHosts != null) {
dumpLog(logger, fromSystemHosts);
return fromSystemHosts;
}
|
1,211 |
dumpLog(logger, fromDefault);
<BUG>}</BUG>
return fromDefault;
}
<BUG>private void dumpLog(final TimingLogger logger, @NonNull List<InetAddress> addresses) {
Log.v(RESOLVER_LOGTAG, "Resolved " + addresses);</BUG>
logger.dumpToLog();
}
<BUG>private void addLogSplit(final TimingLogger logger, String host, String message, int depth) {
final StringBuilder sb = new StringBuilder();</BUG>
for (int i = 0; i < depth; i++) {
|
dumpLog(logger, fromDefault);
return fromDefault;
}
private void dumpLog(final TimingLogger logger, @NonNull List<InetAddress> addresses) {
if (BuildConfig.DEBUG) return;
Log.v(RESOLVER_LOGTAG, "Resolved " + addresses);
logger.dumpToLog();
}
private void addLogSplit(final TimingLogger logger, String host, String message, int depth) {
if (BuildConfig.DEBUG) return;
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < depth; i++) {
|
1,212 |
private final Submit submit;
private final Registry registry;
private final int rmiRegistryPort;
private final Map<String, InstrumentedClass> instrumentedClasses = new HashMap<String, InstrumentedClass>();
private final List<ScriptText> installedScripts = new LinkedList<ScriptText>();
<BUG>private File redirectedSubmissionsFile;
public Instrumentor(Submit submit, int rmiRegistryPort) throws RemoteException</BUG>
{
this.submit = submit;
this.rmiRegistryPort = rmiRegistryPort;
|
private final Submit submit;
private final Registry registry;
private final int rmiRegistryPort;
private final Map<String, InstrumentedClass> instrumentedClasses = new HashMap<String, InstrumentedClass>();
private final List<ScriptText> installedScripts = new LinkedList<ScriptText>();
private File redirectedSubmissionsFile;
private Class<?> helperClass = BytemanTestHelper.class;
public Instrumentor(Submit submit, int rmiRegistryPort) throws RemoteException
{
this.submit = submit;
this.rmiRegistryPort = rmiRegistryPort;
|
1,213 |
import com.cloudant.common.CollectionFactory;
import com.cloudant.sync.internal.common.CouchConstants;
import com.cloudant.common.RequireRunningCouchDB;
import com.cloudant.sync.internal.util.JSONUtils;
import com.cloudant.sync.internal.util.Misc;
<BUG>import org.apache.commons.io.IOUtils;</BUG>
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.io.IOException;
<BUG>import java.io.InputStream;
import java.io.InputStreamReader;</BUG>
import java.util.HashMap;
|
import com.cloudant.common.CollectionFactory;
import com.cloudant.sync.internal.common.CouchConstants;
import com.cloudant.common.RequireRunningCouchDB;
import com.cloudant.sync.internal.util.JSONUtils;
import com.cloudant.sync.internal.util.Misc;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import java.io.IOException;
import java.util.HashMap;
|
1,214 |
Assert.assertEquals("world", doc.get("hello"));
Assert.assertTrue(doc.containsKey(CouchConstants._id));
Assert.assertEquals(res.getId(), doc.get(CouchConstants._id));
Assert.assertTrue(doc.containsKey(CouchConstants._rev));
Assert.assertEquals(res.getRev(), doc.get(CouchConstants._rev));
<BUG>}
@Test(expected = NoResourceException.class)
public void getDocumentInputStream_idNotExist_exception() {
client.getDocumentStream("id_not_exist", "1-no_such_rev");</BUG>
}
|
Assert.assertEquals("world", doc.get("hello"));
Assert.assertTrue(doc.containsKey(CouchConstants._id));
Assert.assertEquals(res.getId(), doc.get(CouchConstants._id));
Assert.assertTrue(doc.containsKey(CouchConstants._rev));
Assert.assertEquals(res.getRev(), doc.get(CouchConstants._rev));
}
|
1,215 |
package com.cloudant.sync.internal.replication;
import com.cloudant.http.HttpConnectionRequestInterceptor;
import com.cloudant.http.HttpConnectionResponseInterceptor;
<BUG>import com.cloudant.sync.internal.mazha.ChangesResult;
import com.cloudant.sync.internal.mazha.CouchClient;
import com.cloudant.sync.internal.mazha.DocumentRevs;</BUG>
import com.cloudant.sync.documentstore.Attachment;
import com.cloudant.sync.documentstore.Database;
|
package com.cloudant.sync.internal.replication;
import com.cloudant.http.HttpConnectionRequestInterceptor;
import com.cloudant.http.HttpConnectionResponseInterceptor;
import com.cloudant.sync.documentstore.Attachment;
import com.cloudant.sync.documentstore.Database;
|
1,216 |
attachmentName);
if (a != null) {
continue;
}
}
<BUG>UnsavedStreamAttachment usa = this.sourceDb
.getAttachmentStream(documentRevs.getId(),
documentRevs.getRev(), attachmentName,
contentType, encoding);
preparedAtts.put(attachmentName, this.targetDb.prepareAttachment(usa, length,
encodedLength));
}</BUG>
}
|
attachmentName);
if (a != null) {
continue;
}
}
preparedAtts.put(attachmentName, this.sourceDb.pullAttachmentWithRetry
(documentRevs.getId(), documentRevs.getRev(), entry
.getKey(), new AttachmentPullProcessor(this
.targetDb, entry.getKey(), contentType,
encoding, length, encodedLength)));
}
}
|
1,217 |
import com.cloudant.sync.internal.mazha.DocumentRevs;
import com.cloudant.sync.internal.mazha.Response;
<BUG>import com.cloudant.sync.internal.documentstore.InternalDocumentRevision;
import com.cloudant.sync.internal.documentstore.DocumentRevsList;
import com.cloudant.sync.internal.documentstore.MultipartAttachmentWriter;
import com.cloudant.sync.documentstore.UnsavedStreamAttachment;</BUG>
import com.cloudant.sync.replication.PullFilter;
import java.util.Collection;
import java.util.List;
import java.util.Map;
|
import com.cloudant.sync.internal.mazha.DocumentRevs;
import com.cloudant.sync.internal.mazha.Response;
import com.cloudant.sync.replication.PullFilter;
import java.util.Collection;
import java.util.List;
import java.util.Map;
|
1,218 |
Map<String, Object> _revisions = ClientTestUtils.getRevisionHistory(revision3, revision2, revision1);
doc1.put(CouchConstants._rev, revision3);
doc1.put(CouchConstants._revisions, _revisions);
List<Response> responses = client.bulkCreateDocs(doc1);
Assert.assertEquals(0, responses.size());
<BUG>Map<String, Object> allRevs = client.getDocRevisions(res1.getId(), revision3, JSONUtils.mapStringToObject());
</BUG>
int revisionStart = (Integer) ((Map<String, Object>) allRevs.get(CouchConstants._revisions)).get
(CouchConstants.start);
Assert.assertEquals(3, revisionStart);
|
Map<String, Object> _revisions = ClientTestUtils.getRevisionHistory(revision3, revision2, revision1);
doc1.put(CouchConstants._rev, revision3);
doc1.put(CouchConstants._revisions, _revisions);
List<Response> responses = client.bulkCreateDocs(doc1);
Assert.assertEquals(0, responses.size());
Map<String, Object> allRevs = client.getDocRevisions(res1.getId(), revision3, JSONUtils.STRING_MAP_TYPE_DEF);
int revisionStart = (Integer) ((Map<String, Object>) allRevs.get(CouchConstants._revisions)).get
(CouchConstants.start);
Assert.assertEquals(3, revisionStart);
|
1,219 |
package com.cloudant.sync.internal.mazha;
<BUG>import com.cloudant.sync.internal.common.RetriableTask;</BUG>
import com.cloudant.http.Http;
import com.cloudant.http.HttpConnection;
import com.cloudant.http.HttpConnectionRequestInterceptor;
<BUG>import com.cloudant.http.HttpConnectionResponseInterceptor;
import com.cloudant.sync.internal.documentstore.DocumentRevsList;</BUG>
import com.cloudant.sync.internal.documentstore.MultipartAttachmentWriter;
|
package com.cloudant.sync.internal.mazha;
import com.cloudant.http.Http;
import com.cloudant.http.HttpConnection;
import com.cloudant.http.HttpConnectionRequestInterceptor;
import com.cloudant.http.HttpConnectionResponseInterceptor;
import com.cloudant.sync.internal.common.RetriableTask;
import com.cloudant.sync.internal.documentstore.DocumentRevsList;
import com.cloudant.sync.internal.documentstore.MultipartAttachmentWriter;
|
1,220 |
return executeResult;
} finally {
IOUtils.closeQuietly(errorStream);
}
}
<BUG>private InputStream executeToInputStreamWithRetry(final Callable<ExecuteResult> task) throws CouchException {
int attempts = 10;
CouchException lastException= null;
</BUG>
while (attempts-- > 0) {
|
return executeResult;
} finally {
IOUtils.closeQuietly(errorStream);
}
}
private <T> T executeWithRetry(final Callable<ExecuteResult> task,
InputStreamProcessor<T> processor) throws
CouchException {
int attempts = 10;
CouchException lastException = null;
while (attempts-- > 0) {
|
1,221 |
public boolean contains(String id) {
Misc.checkNotNullOrEmpty(id, "id");
URI doc = this.uriHelper.documentUri(id);
try {
HttpConnection connection = Http.HEAD(doc);
<BUG>this.executeToInputStreamWithRetry(connection);
return true;</BUG>
} catch (Exception e) {
return false;
}
|
public boolean contains(String id) {
Misc.checkNotNullOrEmpty(id, "id");
URI doc = this.uriHelper.documentUri(id);
try {
HttpConnection connection = Http.HEAD(doc);
this.executeWithRetry(connection, new NoOpInputStreamProcessor());
return true;
} catch (Exception e) {
return false;
|
1,222 |
final URI doc = this.uriHelper.attachmentUri(id, queries, attachmentName);
HttpConnection connection = Http.GET(doc);
if (acceptGzip) {
connection.requestProperties.put("Accept-Encoding", "gzip");
}
<BUG>return executeToInputStreamWithRetry(connection);
</BUG>
}
public void putAttachmentStream(String id, String rev, String attachmentName, String contentType, byte[] attachmentData) {
Misc.checkNotNullOrEmpty(id, "id");
|
final URI doc = this.uriHelper.attachmentUri(id, queries, attachmentName);
HttpConnection connection = Http.GET(doc);
if (acceptGzip) {
connection.requestProperties.put("Accept-Encoding", "gzip");
}
return executeWithRetry(connection, processor);
}
public void putAttachmentStream(String id, String rev, String attachmentName, String contentType, byte[] attachmentData) {
Misc.checkNotNullOrEmpty(id, "id");
|
1,223 |
} else {
options.put("attachments", false);
options.put("att_encoding_info", true);
}
options.put("open_revs", JSONUtils.toJson(revisions));
<BUG>return this.getDocument(id, options, JSONUtils.openRevisionList());
}</BUG>
public Iterable<DocumentRevsList> bulkReadDocsWithOpenRevisions(List<BulkGetRequest> request,
boolean pullAttachmentsInline) {
Map<String, Object> options = new HashMap<String, Object>();
|
} else {
options.put("attachments", false);
options.put("att_encoding_info", true);
}
options.put("open_revs", JSONUtils.toJson(revisions));
return this.getDocument(id, options, JSONUtils.OPEN_REVS_LIST_TYPE_DEF);
}
public Iterable<DocumentRevsList> bulkReadDocsWithOpenRevisions(List<BulkGetRequest> request,
boolean pullAttachmentsInline) {
Map<String, Object> options = new HashMap<String, Object>();
|
1,224 |
Misc.checkNotNull(rev, "Revision ID");
Map<String, Object> queries = new HashMap<String, Object>();
queries.put("revs", "true");
queries.put("rev", rev);
URI findRevs = this.uriHelper.documentUri(id, queries);
<BUG>InputStream is = null;
try {
HttpConnection connection = Http.GET(findRevs);
is = this.executeToInputStreamWithRetry(connection);
return JSONUtils.fromJson(new InputStreamReader(is, Charset.forName("UTF-8")), type);
} finally {
closeQuietly(is);
}</BUG>
}
|
Misc.checkNotNull(rev, "Revision ID");
Map<String, Object> queries = new HashMap<String, Object>();
queries.put("revs", "true");
queries.put("rev", rev);
URI findRevs = this.uriHelper.documentUri(id, queries);
HttpConnection connection = Http.GET(findRevs);
return executeToJsonObjectWithRetry(connection, type);
}
|
1,225 |
String payload = JSONUtils.toJson(revisions);
<BUG>InputStream is = null;
try {</BUG>
HttpConnection connection = Http.POST(uri, "application/json");
<BUG>connection.setRequestBody(payload);
is = executeToInputStreamWithRetry(connection);
return JSONUtils.fromJson(new InputStreamReader(is, Charset.forName("UTF-8")),
JSONUtils.mapStringMissingRevisions());
} finally {
closeQuietly(is);
}</BUG>
}
|
String payload = JSONUtils.toJson(revisions);
HttpConnection connection = Http.POST(uri, "application/json");
connection.setRequestBody(payload);
return executeToJsonObjectWithRetry(connection, JSONUtils.STRING_MISSING_REVS_MAP_TYPE_DEF);
}
|
1,226 |
selenium.click(RuntimeVariables.replace("//b"));
selenium.waitForPageToLoad("30000");
selenium.click(RuntimeVariables.replace(
"//input[@value='Add Subfolder']"));
selenium.waitForPageToLoad("30000");
<BUG>selenium.typeKeys("_31_name", RuntimeVariables.replace("Test Image.jpg"));
selenium.type("_31_name", RuntimeVariables.replace("Test Image.jpg"));
</BUG>
selenium.type("_31_description",
RuntimeVariables.replace("Image Name Title Folder Test"));
|
selenium.click(RuntimeVariables.replace("//b"));
selenium.waitForPageToLoad("30000");
selenium.click(RuntimeVariables.replace(
"//input[@value='Add Subfolder']"));
selenium.waitForPageToLoad("30000");
selenium.type("_31_name", RuntimeVariables.replace("Test1 Image1.jpg"));
selenium.type("_31_description",
RuntimeVariables.replace("Image Name Title Folder Test"));
|
1,227 |
}
selenium.click("link=Use the classic uploader.");
selenium.type("_31_file",
RuntimeVariables.replace(
"L:\\portal\\build\\portal-web\\test\\com\\liferay\\portalweb\\portlet\\imagegallery\\test_image.jpg"));
<BUG>selenium.typeKeys("_31_name", RuntimeVariables.replace("Test Image"));
selenium.type("_31_name", RuntimeVariables.replace("Test Image"));
</BUG>
selenium.type("_31_description",
<BUG>RuntimeVariables.replace("This is the Liferay logo!"));
</BUG>
selenium.click(RuntimeVariables.replace("//input[@value='Save']"));
|
}
try {
if (selenium.isElementPresent("link=Image Gallery Test Page")) {
break;
}
}
catch (Exception e) {
}
Thread.sleep(1000);
}
selenium.click(RuntimeVariables.replace("link=Image Gallery Test Page"));
|
1,228 |
private static final int NOTIFICATION_ITEM = 541;
private static int last_level = -1;
private static boolean notification_showing = false;
private static int threshold = 20;
private static final int repeat_seconds = 1200;
<BUG>public static void checkBridgeBattery() {
if (!Home.getPreferencesBooleanDefaultFalse("bridge_battery_alerts")) return;
</BUG>
try {
|
private static final int NOTIFICATION_ITEM = 541;
private static int last_level = -1;
private static boolean notification_showing = false;
private static int threshold = 20;
private static final int repeat_seconds = 1200;
public static boolean checkBridgeBattery() {
boolean lowbattery = false;
if (!Home.getPreferencesBooleanDefaultFalse("bridge_battery_alerts")) return false;
try {
|
1,229 |
}
final int this_level = Home.getPreferencesInt("bridge_battery", -1);
if ((this_level > 0) && (threshold > 0)) {
if ((this_level < threshold) && (this_level < last_level)) {
if (JoH.pratelimit("bridge-battery-warning", repeat_seconds)) {
<BUG>notification_showing = true;
final PendingIntent pendingIntent = android.app.PendingIntent.getActivity(xdrip.getAppContext(), 0, new Intent(xdrip.getAppContext(), Home.class), android.app.PendingIntent.FLAG_UPDATE_CURRENT);</BUG>
showNotification("Low bridge battery", "Bridge battery dropped to: " + this_level + "%", pendingIntent, NOTIFICATION_ITEM, true, true, false);
}
} else {
|
}
final int this_level = Home.getPreferencesInt("bridge_battery", -1);
if ((this_level > 0) && (threshold > 0)) {
if ((this_level < threshold) && (this_level < last_level)) {
if (JoH.pratelimit("bridge-battery-warning", repeat_seconds)) {
notification_showing = true;
lowbattery = true;
final PendingIntent pendingIntent = android.app.PendingIntent.getActivity(xdrip.getAppContext(), 0, new Intent(xdrip.getAppContext(), Home.class), android.app.PendingIntent.FLAG_UPDATE_CURRENT);
showNotification("Low bridge battery", "Bridge battery dropped to: " + this_level + "%", pendingIntent, NOTIFICATION_ITEM, true, true, false);
}
} else {
|
1,230 |
cancelNotification(NOTIFICATION_ITEM);
notification_showing = false;
}
}
last_level = this_level;
<BUG>}
}</BUG>
public static void testHarness() {
if (Home.getPreferencesInt(PREFS_ITEM, -1) < 1)
Home.setPreferencesInt(PREFS_ITEM, 60);
|
cancelNotification(NOTIFICATION_ITEM);
notification_showing = false;
}
}
last_level = this_level;
}
return lowbattery;
}
public static void testHarness() {
if (Home.getPreferencesInt(PREFS_ITEM, -1) < 1)
Home.setPreferencesInt(PREFS_ITEM, 60);
|
1,231 |
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
<BUG>import android.util.Log;
import com.eveningoutpost.dexdrip.Home;</BUG>
import com.eveningoutpost.dexdrip.Models.ActiveBluetoothDevice;
import com.eveningoutpost.dexdrip.Models.AlertType;
import com.eveningoutpost.dexdrip.Models.BgReading;
|
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
import com.eveningoutpost.dexdrip.Home;
import com.eveningoutpost.dexdrip.Models.ActiveBluetoothDevice;
import com.eveningoutpost.dexdrip.Models.AlertType;
import com.eveningoutpost.dexdrip.Models.BgReading;
|
1,232 |
private static final String WEARABLE_FIELD_PAYLOAD = "field_xdrip_plus_payload";
public static final String WEARABLE_VOICE_PAYLOAD = "/xdrip_plus_voice_payload";
public static final String WEARABLE_APPROVE_TREATMENT = "/xdrip_plus_approve_treatment";
public static final String WEARABLE_CANCEL_TREATMENT = "/xdrip_plus_cancel_treatment";
private static final String WEARABLE_TREATMENT_PAYLOAD = "/xdrip_plus_treatment_payload";
<BUG>private static final String WEARABLE_TOAST_NOTIFICATON = "/xdrip_plus_toast";
private static final String OPEN_SETTINGS_PATH = "/openwearsettings";</BUG>
private static final String NEW_STATUS_PATH = "/sendstatustowear";//KS
private static final String CAPABILITY_WEAR_APP = "wear_app_sync_bgs";
private String mWearNodeId = null;
|
private static final String WEARABLE_FIELD_PAYLOAD = "field_xdrip_plus_payload";
public static final String WEARABLE_VOICE_PAYLOAD = "/xdrip_plus_voice_payload";
public static final String WEARABLE_APPROVE_TREATMENT = "/xdrip_plus_approve_treatment";
public static final String WEARABLE_CANCEL_TREATMENT = "/xdrip_plus_cancel_treatment";
private static final String WEARABLE_TREATMENT_PAYLOAD = "/xdrip_plus_treatment_payload";
private static final String WEARABLE_TOAST_NOTIFICATON = "/xdrip_plus_toast";
private static final String WEARABLE_TOAST_LOCAL_NOTIFICATON = "/xdrip_plus_local_toast";
private static final String OPEN_SETTINGS_PATH = "/openwearsettings";
private static final String NEW_STATUS_PATH = "/sendstatustowear";//KS
private static final String CAPABILITY_WEAR_APP = "wear_app_sync_bgs";
private String mWearNodeId = null;
|
1,233 |
sharedPrefs.edit().putString("chart_timeframe", "" + timeframe).commit();
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this)
<BUG>.setAcceptsTapEvents(true)
.setStatusBarGravity(Gravity.END | -20)</BUG>
.build();
}
@Override
|
sharedPrefs.edit().putString("chart_timeframe", "" + timeframe).commit();
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this)
.setAcceptsTapEvents(true)
.setHotwordIndicatorGravity(Gravity.TOP | Gravity.CENTER)
.setStatusBarGravity(Gravity.END | -20)
.build();
}
@Override
|
1,234 |
DataMap dataMap;
Bundle bundle = intent.getBundleExtra("msg");
if (layoutSet && bundle != null) {
dataMap = DataMap.fromBundle(bundle);
String msg = dataMap.getString("msg", "");
<BUG>JoH.static_toast_long(msg);
}</BUG>
bundle = intent.getBundleExtra("steps");
if (layoutSet && bundle != null) {
<BUG>dataMap = DataMap.fromBundle(bundle);
mStepsCount = dataMap.getInt("steps", 0);
mTimeStepsRcvd = dataMap.getLong("steps_timestamp", 0);
}</BUG>
bundle = intent.getBundleExtra(Home.HOME_FULL_WAKEUP);
|
DataMap dataMap;
Bundle bundle = intent.getBundleExtra("msg");
if (layoutSet && bundle != null) {
dataMap = DataMap.fromBundle(bundle);
String msg = dataMap.getString("msg", "");
int length = dataMap.getInt("length", 0);
JoH.static_toast(xdrip.getAppContext(), msg, length);
}
bundle = intent.getBundleExtra("steps");
if (layoutSet && bundle != null) {
dataMap = DataMap.fromBundle(bundle);
if (mTimeStepsRcvd <= dataMap.getLong("steps_timestamp", 0)) {
|
1,235 |
return false;
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this)
<BUG>.setAcceptsTapEvents(true)
.setStatusBarGravity(Gravity.END | -20)</BUG>
.build();
}
@Override
|
return false;
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this)
.setAcceptsTapEvents(true)
.setHotwordIndicatorGravity(Gravity.TOP | Gravity.END)
.setStatusBarGravity(Gravity.END | -20)
.build();
}
@Override
|
1,236 |
return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN) || (watchMode == WatchMode.LOW_BIT_BURN_IN);
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this)
<BUG>.setAcceptsTapEvents(true)
.setStatusBarGravity(Gravity.END | -20)</BUG>
.build();
}
public int ageLevel() {
|
return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN) || (watchMode == WatchMode.LOW_BIT_BURN_IN);
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this)
.setAcceptsTapEvents(true)
.setHotwordIndicatorGravity(Gravity.TOP | Gravity.CENTER)
.setStatusBarGravity(Gravity.END | -20)
.build();
}
public int ageLevel() {
|
1,237 |
DataMap dataMap;
Bundle bundle = intent.getBundleExtra("msg");
if (layoutSet && bundle != null) {
dataMap = DataMap.fromBundle(bundle);
String msg = dataMap.getString("msg", "");
<BUG>JoH.static_toast_short(msg);
}</BUG>
bundle = intent.getBundleExtra("steps");
if (layoutSet && bundle != null) {
<BUG>dataMap = DataMap.fromBundle(bundle);
mStepsCount = dataMap.getInt("steps", 0);
mTimeStepsRcvd = dataMap.getLong("steps_timestamp", 0);
}</BUG>
bundle = intent.getBundleExtra("data");
|
DataMap dataMap;
Bundle bundle = intent.getBundleExtra("msg");
if (layoutSet && bundle != null) {
dataMap = DataMap.fromBundle(bundle);
String msg = dataMap.getString("msg", "");
int length = dataMap.getInt("length", 0);
JoH.static_toast(xdrip.getAppContext(), msg, length);
}
bundle = intent.getBundleExtra("steps");
if (layoutSet && bundle != null) {
dataMap = DataMap.fromBundle(bundle);
if (mTimeStepsRcvd <= dataMap.getLong("steps_timestamp", 0)) {
|
1,238 |
myLayout.draw(canvas);
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this)
<BUG>.setAcceptsTapEvents(true)
.setStatusBarGravity(Gravity.END | -20)</BUG>
.build();
}
@Override
|
myLayout.draw(canvas);
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this)
.setAcceptsTapEvents(true)
.setHotwordIndicatorGravity(Gravity.TOP | Gravity.CENTER)
.setStatusBarGravity(Gravity.END | -20)
.build();
}
@Override
|
1,239 |
DataMap dataMap;
Bundle bundle = intent.getBundleExtra("msg");
if (bundle != null) {
dataMap = DataMap.fromBundle(bundle);
String msg = dataMap.getString("msg", "");
<BUG>JoH.static_toast_short(msg);
}</BUG>
bundle = intent.getBundleExtra("steps");
if (bundle != null) {
<BUG>dataMap = DataMap.fromBundle(bundle);
mStepsCount = dataMap.getInt("steps", 0);
mTimeStepsRcvd = dataMap.getLong("steps_timestamp", 0);
}</BUG>
bundle = intent.getBundleExtra("data");
|
DataMap dataMap;
Bundle bundle = intent.getBundleExtra("msg");
if (bundle != null) {
dataMap = DataMap.fromBundle(bundle);
String msg = dataMap.getString("msg", "");
int length = dataMap.getInt("length", 0);
JoH.static_toast(xdrip.getAppContext(), msg, length);
}
bundle = intent.getBundleExtra("steps");
if (bundle != null) {
dataMap = DataMap.fromBundle(bundle);
if (mTimeStepsRcvd <= dataMap.getLong("steps_timestamp", 0)) {
|
1,240 |
import board.items.BrdItem;
import board.items.BrdTracep;
import board.varie.BrdKeepPoint;
import freert.planar.PlaDirection;
import freert.planar.PlaLimits;
<BUG>import freert.planar.PlaLineInt;
import freert.planar.PlaPoint;</BUG>
import freert.planar.PlaPointFloat;
import freert.planar.PlaPointInt;
import freert.planar.PlaSide;
|
import board.items.BrdItem;
import board.items.BrdTracep;
import board.varie.BrdKeepPoint;
import freert.planar.PlaDirection;
import freert.planar.PlaLimits;
import freert.planar.PlaLineInt;
import freert.planar.PlaLineIntAlist;
import freert.planar.PlaPoint;
import freert.planar.PlaPointFloat;
import freert.planar.PlaPointInt;
import freert.planar.PlaSide;
|
1,241 |
for (int index = 1; index < line_arr.length - 2; ++index)
</BUG>
{
<BUG>PlaDirection d1 = line_arr[index].direction();
PlaDirection d2 = line_arr[index + 1].direction();
</BUG>
if (d1.is_multiple_of_45_degree() && d2.is_multiple_of_45_degree() && d1.projection(d2) != Signum.POSITIVE)
{
|
boolean polyline_changed = true;
while (polyline_changed)
{
if (p_polyline.plaline_len() < 4) return p_polyline;
polyline_changed = false;
PlaLineIntAlist line_arr = p_polyline.alist_copy(0);
for (int index = 1; index < line_arr.size() - 2; ++index)
{
PlaDirection d1 = line_arr.get(index).direction();
PlaDirection d2 = line_arr.get(index + 1).direction();
if (d1.is_multiple_of_45_degree() && d2.is_multiple_of_45_degree() && d1.projection(d2) != Signum.POSITIVE)
{
|
1,242 |
}
PlaLineInt result = translate_line.translate(translate_dist);
r_board.changed_area.join(curr_corner, curr_layer);
return result;
}
<BUG>private PlaLineInt smoothen_non_integer_corner(PlaLineInt[] p_line_arr, int p_no)
</BUG>
{
<BUG>PlaLineInt prev_line = p_line_arr[p_no];
PlaLineInt next_line = p_line_arr[p_no + 1];
</BUG>
if (prev_line.is_equal_or_opposite(next_line))
|
}
if (new_line == null) continue;
polyline_changed = true;
PlaLineIntAlist tmp_lines = new PlaLineIntAlist(line_arr.size() + 1);
line_arr.append_to(tmp_lines, 0, index + 1);
tmp_lines.add(new_line);
line_arr.append_to(tmp_lines, index + 2);
line_arr = tmp_lines;
++index;
}
}
if (polyline_changed)
|
1,243 |
if (!(prev_line.is_diagonal() && next_line.is_diagonal()))
{
return null;
}
PlaPointFloat curr_corner = prev_line.intersection_approx(next_line);
<BUG>PlaPointFloat prev_corner = prev_line.intersection_approx(p_line_arr[p_no - 1]);
PlaPointFloat next_corner = next_line.intersection_approx(p_line_arr[p_no + 2]);
</BUG>
PlaLineInt result = null;
|
if (!(prev_line.is_diagonal() && next_line.is_diagonal()))
{
return null;
}
PlaPointFloat curr_corner = prev_line.intersection_approx(next_line);
PlaPointFloat prev_corner = prev_line.intersection_approx(p_line_arr.get(p_no - 1));
PlaPointFloat next_corner = next_line.intersection_approx(p_line_arr.get(p_no + 2));
PlaLineInt result = null;
|
1,244 |
{
<BUG>PlaPointFloat prev_corner = p_line_arr[p_no].intersection_approx(p_line_arr[p_no - 1]);
</BUG>
if ( prev_corner.is_NaN()) return null;
<BUG>PlaPointFloat curr_corner = p_line_arr[p_no].intersection_approx(p_line_arr[p_no + 1]);
</BUG>
if ( curr_corner.is_NaN()) return null;
<BUG>PlaPointFloat next_corner = p_line_arr[p_no + 1].intersection_approx(p_line_arr[p_no + 2]);
</BUG>
if ( next_corner.is_NaN()) return null;
|
{
PlaLineInt prev_line = p_line_arr.get(p_no);
PlaLineInt next_line = p_line_arr.get(p_no + 1);
if (prev_line.is_equal_or_opposite(next_line))
{
|
1,245 |
if ( curr_corner.is_NaN()) return null;
<BUG>PlaPointFloat next_corner = p_line_arr[p_no + 1].intersection_approx(p_line_arr[p_no + 2]);
</BUG>
if ( next_corner.is_NaN()) return null;
<BUG>PlaDirection prev_dir = p_line_arr[p_no].direction();
PlaDirection next_dir = p_line_arr[p_no + 1].direction();
</BUG>
PlaDirection new_line_dir = prev_dir.add(next_dir);
PlaLineInt translate_line = new PlaLineInt(curr_corner.round(), new_line_dir);
|
if ( curr_corner.is_NaN()) return null;
PlaPointFloat next_corner = p_line_arr.get(p_no + 1).intersection_approx(p_line_arr.get(p_no + 2));
if ( next_corner.is_NaN()) return null;
PlaDirection prev_dir = p_line_arr.get(p_no).direction();
PlaDirection next_dir = p_line_arr.get(p_no + 1).direction();
PlaDirection new_line_dir = prev_dir.add(next_dir);
PlaLineInt translate_line = new PlaLineInt(curr_corner.round(), new_line_dir);
|
1,246 |
if (translate_line.side_of(next_corner) == PlaSide.ON_THE_LEFT)
{
max_translate_dist = -max_translate_dist;
}
PlaLineInt[] check_lines = new PlaLineInt[3];
<BUG>check_lines[0] = p_line_arr[p_no];
check_lines[2] = p_line_arr[p_no + 1];
</BUG>
double translate_dist = max_translate_dist;
|
if (translate_line.side_of(next_corner) == PlaSide.ON_THE_LEFT)
{
max_translate_dist = -max_translate_dist;
}
PlaLineInt[] check_lines = new PlaLineInt[3];
check_lines[0] = p_line_arr.get(p_no);
check_lines[2] = p_line_arr.get(p_no + 1);
double translate_dist = max_translate_dist;
|
1,247 |
double delta_dist = max_translate_dist;
PlaSide side_of_nearest_point = translate_line.side_of(nearest_point);
int sign = Signum.as_int(max_translate_dist);
PlaLineInt new_line = null;
PlaLineInt[] check_lines = new PlaLineInt[3];
<BUG>check_lines[0] = p_line_arr[p_no - 1];
check_lines[2] = p_line_arr[p_no + 1];
</BUG>
boolean first_time = true;
|
double delta_dist = max_translate_dist;
PlaSide side_of_nearest_point = translate_line.side_of(nearest_point);
int sign = Signum.as_int(max_translate_dist);
PlaLineInt new_line = null;
PlaLineInt[] check_lines = new PlaLineInt[3];
check_lines[0] = p_line_arr.get(p_no - 1);
check_lines[2] = p_line_arr.get(p_no + 1);
boolean first_time = true;
|
1,248 |
return new_line;
}
private Polyline reposition_lines(Polyline p_polyline)
{
if (p_polyline.plaline_len() < 5) return p_polyline;
<BUG>PlaLineInt[] line_arr = p_polyline.alist_to_array();
</BUG>
for (int index = 2; index < p_polyline.plaline_len(-2); ++index)
{
PlaLineInt new_line = reposition_line(line_arr, index);
|
return new_line;
}
private Polyline reposition_lines(Polyline p_polyline)
{
if (p_polyline.plaline_len() < 5) return p_polyline;
PlaLineIntAlist line_arr = p_polyline.alist_copy(0);
for (int index = 2; index < p_polyline.plaline_len(-2); ++index)
{
PlaLineInt new_line = reposition_line(line_arr, index);
|
1,249 |
</BUG>
for (int index = 2; index < p_polyline.plaline_len(-2); ++index)
{
PlaLineInt new_line = reposition_line(line_arr, index);
if (new_line == null) continue;
<BUG>line_arr[index] = new_line;
</BUG>
Polyline result = new Polyline(line_arr);
return skip_segments_of_length_0(result);
}
|
return new_line;
}
private Polyline reposition_lines(Polyline p_polyline)
{
if (p_polyline.plaline_len() < 5) return p_polyline;
PlaLineIntAlist line_arr = p_polyline.alist_copy(0);
for (int index = 2; index < p_polyline.plaline_len(-2); ++index)
{
PlaLineInt new_line = reposition_line(line_arr, index);
if (new_line == null) continue;
line_arr.set(index, new_line);
Polyline result = new Polyline(line_arr);
return skip_segments_of_length_0(result);
}
|
1,250 |
return new Polyline(new_lines);
}
}
else if (bend)
{
<BUG>PlaLineInt[] check_line_arr = new PlaLineInt[trace_polyline.plaline_len(+1)];
for (int index = 0; index < trace_polyline.plaline_len(-1); ++index)
{
check_line_arr[index] = trace_polyline.plaline(index);
}
check_line_arr[check_line_arr.length - 2] = other_trace_line;
check_line_arr[check_line_arr.length - 1] = other_prev_trace_line;</BUG>
PlaLineInt new_line = reposition_line(check_line_arr, trace_polyline.plaline_len(-2));
|
return new Polyline(new_lines);
}
}
else if (bend)
{
PlaLineIntAlist check_line_arr = new PlaLineIntAlist(trace_polyline.plaline_len(+1));
trace_polyline.alist_append_to(check_line_arr, 0,trace_polyline.plaline_len(-1));
check_line_arr.add( other_trace_line);
check_line_arr.add( other_prev_trace_line);
PlaLineInt new_line = reposition_line(check_line_arr, trace_polyline.plaline_len(-2));
|
1,251 |
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
<BUG>import java.util.List;
import io.vertigo.commons.analytics.AnalyticsManager;</BUG>
import io.vertigo.commons.analytics.AnalyticsTracker;
import io.vertigo.dynamo.database.connection.SqlConnection;
import io.vertigo.dynamo.database.statement.SqlPreparedStatement;
|
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import io.vertigo.commons.analytics.AnalyticsManager;
import io.vertigo.commons.analytics.AnalyticsTracker;
import io.vertigo.dynamo.database.connection.SqlConnection;
import io.vertigo.dynamo.database.statement.SqlPreparedStatement;
|
1,252 |
private static FGStorageManager instance;
private final Logger logger = FoxGuardMain.instance().getLogger();</BUG>
private final Set<LoadEntry> loaded = new HashSet<>();
private final Path directory = getDirectory();
private final Map<String, Path> worldDirectories;
<BUG>private FGStorageManager() {
defaultModifiedMap = new CacheMap<>((k, m) -> {</BUG>
if (k instanceof IFGObject) {
m.put((IFGObject) k, true);
return true;
|
private static FGStorageManager instance;
public final HashMap<IFGObject, Boolean> defaultModifiedMap;
private final UserStorageService userStorageService;
private final Logger logger = FoxGuardMain.instance().getLogger();
private final Set<LoadEntry> loaded = new HashSet<>();
private final Path directory = getDirectory();
private final Map<String, Path> worldDirectories;
private FGStorageManager() {
userStorageService = FoxGuardMain.instance().getUserStorage();
defaultModifiedMap = new CacheMap<>((k, m) -> {
if (k instanceof IFGObject) {
m.put((IFGObject) k, true);
return true;
|
1,253 |
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving region \"" + name + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving region " + logName + "!", e);
}
logger.info("Saving metadata for region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,254 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
</BUG>
}
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + logName + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
|
1,255 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("Region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("Region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,256 |
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving world region \"" + name + "\" in world \"" + world.getName() + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for world region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving world region " + logName + " in world " + world.getName() + "!", e);
}
logger.info("Saving metadata for world region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,257 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
</BUG>
}
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + logName + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
|
1,258 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("World region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("World region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,259 |
String name = fgObject.getName();
Path singleDir = dir.resolve(name.toLowerCase());
</BUG>
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
<BUG>logger.info((shouldSave ? "S" : "Force s") + "aving handler \"" + name + "\" in directory: " + singleDir);
</BUG>
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
String name = fgObject.getName();
UUID owner = fgObject.getOwner();
boolean isOwned = !owner.equals(SERVER_UUID);
Optional<User> userOwner = userStorageService.get(owner);
String logName = (userOwner.isPresent() ? userOwner.get().getName() + ":" : "") + (isOwned ? owner + ":" : "") + name;
if (fgObject.autoSave()) {
Path singleDir = serverDir.resolve(name.toLowerCase());
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
logger.info((shouldSave ? "S" : "Force s") + "aving handler " + logName + " in directory: " + singleDir);
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
1,260 |
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving region \"" + name + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving region " + logName + "!", e);
}
logger.info("Saving metadata for region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,261 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
</BUG>
}
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + logName + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
|
1,262 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("Region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("Region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,263 |
if (fgObject.autoSave()) {
Path singleDir = dir.resolve(name.toLowerCase());
</BUG>
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
<BUG>logger.info((shouldSave ? "S" : "Force s") + "aving world region \"" + name + "\" in directory: " + singleDir);
</BUG>
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
if (fgObject.autoSave()) {
Path singleDir = serverDir.resolve(name.toLowerCase());
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
logger.info((shouldSave ? "S" : "Force s") + "aving world region " + logName + " in directory: " + singleDir);
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
1,264 |
</BUG>
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving world region \"" + name + "\" in world \"" + world.getName() + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for world region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
if (fgObject.autoSave()) {
Path singleDir = serverDir.resolve(name.toLowerCase());
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
logger.info((shouldSave ? "S" : "Force s") + "aving world region " + logName + " in directory: " + singleDir);
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving world region " + logName + " in world " + world.getName() + "!", e);
}
logger.info("Saving metadata for world region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,265 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
}</BUG>
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + name + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
|
1,266 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("World region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("World region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,267 |
public synchronized void loadRegionLinks() {
logger.info("Loading region links");
try (DB mainDB = DBMaker.fileDB(directory.resolve("regions.foxdb").normalize().toString()).make()) {
Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen();
linksMap.entrySet().forEach(entry -> {
<BUG>IRegion region = FGManager.getInstance().getRegion(entry.getKey());
if (region != null) {
logger.info("Loading links for region \"" + region.getName() + "\"");</BUG>
String handlersString = entry.getValue();
|
public synchronized void loadRegionLinks() {
logger.info("Loading region links");
try (DB mainDB = DBMaker.fileDB(directory.resolve("regions.foxdb").normalize().toString()).make()) {
Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen();
linksMap.entrySet().forEach(entry -> {
Optional<IRegion> regionOpt = FGManager.getInstance().getRegion(entry.getKey());
if (regionOpt.isPresent()) {
IRegion region = regionOpt.get();
logger.info("Loading links for region \"" + region.getName() + "\"");
String handlersString = entry.getValue();
|
1,268 |
public synchronized void loadWorldRegionLinks(World world) {
logger.info("Loading world region links for world \"" + world.getName() + "\"");
try (DB mainDB = DBMaker.fileDB(worldDirectories.get(world.getName()).resolve("wregions.foxdb").normalize().toString()).make()) {
Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen();
linksMap.entrySet().forEach(entry -> {
<BUG>IRegion region = FGManager.getInstance().getWorldRegion(world, entry.getKey());
if (region != null) {
logger.info("Loading links for world region \"" + region.getName() + "\"");</BUG>
String handlersString = entry.getValue();
|
public synchronized void loadWorldRegionLinks(World world) {
logger.info("Loading world region links for world \"" + world.getName() + "\"");
try (DB mainDB = DBMaker.fileDB(worldDirectories.get(world.getName()).resolve("wregions.foxdb").normalize().toString()).make()) {
Map<String, String> linksMap = mainDB.hashMap("links", Serializer.STRING, Serializer.STRING).createOrOpen();
linksMap.entrySet().forEach(entry -> {
Optional<IWorldRegion> regionOpt = FGManager.getInstance().getWorldRegion(world, entry.getKey());
if (regionOpt.isPresent()) {
IWorldRegion region = regionOpt.get();
logger.info("Loading links for world region \"" + region.getName() + "\"");
String handlersString = entry.getValue();
|
1,269 |
StringBuilder builder = new StringBuilder();
for (Iterator<IHandler> it = handlers.iterator(); it.hasNext(); ) {
builder.append(it.next().getName());
if (it.hasNext()) builder.append(",");
}
<BUG>return builder.toString();
}</BUG>
private final class LoadEntry {
public final String name;
public final Type type;
|
StringBuilder builder = new StringBuilder();
for (Iterator<IHandler> it = handlers.iterator(); it.hasNext(); ) {
builder.append(it.next().getName());
if (it.hasNext()) builder.append(",");
}
return builder.toString();
}
public enum Type {
REGION, WREGION, HANDLER
}
private final class LoadEntry {
public final String name;
public final Type type;
|
1,270 |
import org.spongepowered.api.world.Locatable;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import javax.annotation.Nullable;
import java.util.*;
<BUG>import java.util.stream.Collectors;
import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;</BUG>
public class CommandHere extends FCCommandBase {
private static final String[] PRIORITY_ALIASES = {"priority", "prio", "p"};
private static final FlagMapper MAPPER = map -> key -> value -> {
|
import org.spongepowered.api.world.Locatable;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;
public class CommandHere extends FCCommandBase {
private static final String[] PRIORITY_ALIASES = {"priority", "prio", "p"};
private static final FlagMapper MAPPER = map -> key -> value -> {
|
1,271 |
import net.foxdenstudio.sponge.foxguard.plugin.handler.GlobalHandler;
import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler;
import net.foxdenstudio.sponge.foxguard.plugin.object.IFGObject;
import net.foxdenstudio.sponge.foxguard.plugin.object.IGlobal;
import net.foxdenstudio.sponge.foxguard.plugin.region.IRegion;
<BUG>import net.foxdenstudio.sponge.foxguard.plugin.region.world.GlobalWorldRegion;</BUG>
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.ArgumentParseException;
<BUG>import org.spongepowered.api.entity.living.player.Player;</BUG>
import org.spongepowered.api.text.Text;
|
import net.foxdenstudio.sponge.foxguard.plugin.handler.GlobalHandler;
import net.foxdenstudio.sponge.foxguard.plugin.handler.IHandler;
import net.foxdenstudio.sponge.foxguard.plugin.object.IFGObject;
import net.foxdenstudio.sponge.foxguard.plugin.object.IGlobal;
import net.foxdenstudio.sponge.foxguard.plugin.region.IRegion;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.ArgumentParseException;
import org.spongepowered.api.text.Text;
|
1,272 |
import org.spongepowered.api.world.Locatable;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import javax.annotation.Nullable;
import java.util.List;
<BUG>import java.util.Optional;
import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;</BUG>
public class CommandDelete extends FCCommandBase {
private static final FlagMapper MAPPER = map -> key -> value -> {
map.put(key, value);
|
import org.spongepowered.api.world.Locatable;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import static net.foxdenstudio.sponge.foxcore.plugin.util.Aliases.*;
public class CommandDelete extends FCCommandBase {
private static final FlagMapper MAPPER = map -> key -> value -> {
map.put(key, value);
|
1,273 |
.append(Text.of(TextColors.GREEN, "Usage: "))
.append(getUsage(source))
.build());
return CommandResult.empty();
} else if (isIn(REGIONS_ALIASES, parse.args[0])) {
<BUG>if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!"));
IRegion region = FGManager.getInstance().getRegion(parse.args[1]);
</BUG>
boolean isWorldRegion = false;
if (region == null) {
|
.append(Text.of(TextColors.GREEN, "Usage: "))
.append(getUsage(source))
.build());
return CommandResult.empty();
} else if (isIn(REGIONS_ALIASES, parse.args[0])) {
if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!"));
String regionName = parse.args[1];
IRegion region = FGManager.getInstance().getRegion(regionName).orElse(null);
boolean isWorldRegion = false;
if (region == null) {
|
1,274 |
</BUG>
isWorldRegion = true;
}
if (region == null)
<BUG>throw new CommandException(Text.of("No region exists with the name \"" + parse.args[1] + "\"!"));
if (region instanceof GlobalWorldRegion) {
</BUG>
throw new CommandException(Text.of("You may not delete the global region!"));
}
|
if (world == null)
throw new CommandException(Text.of("No world exists with name \"" + worldName + "\"!"));
}
}
if (world == null) throw new CommandException(Text.of("Must specify a world!"));
region = FGManager.getInstance().getWorldRegion(world, regionName).orElse(null);
isWorldRegion = true;
}
if (region == null)
throw new CommandException(Text.of("No region exists with the name \"" + regionName + "\"!"));
if (region instanceof IGlobal) {
throw new CommandException(Text.of("You may not delete the global region!"));
}
|
1,275 |
source.getName() + " deleted " + (isWorldRegion ? "world" : "") + "region"
);
return CommandResult.success();
} else if (isIn(HANDLERS_ALIASES, parse.args[0])) {
if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!"));
<BUG>IHandler handler = FGManager.getInstance().gethandler(parse.args[1]);
if (handler == null)
throw new ArgumentParseException(Text.of("No handler exists with that name!"), parse.args[1], 1);
if (handler instanceof GlobalHandler)</BUG>
throw new CommandException(Text.of("You may not delete the global handler!"));
|
source.getName() + " deleted " + (isWorldRegion ? "world" : "") + "region"
);
return CommandResult.success();
} else if (isIn(HANDLERS_ALIASES, parse.args[0])) {
if (parse.args.length < 2) throw new CommandException(Text.of("Must specify a name!"));
Optional<IHandler> handlerOpt = FGManager.getInstance().gethandler(parse.args[1]);
if (!handlerOpt.isPresent())
throw new ArgumentParseException(Text.of("No handler exists with that name!"), parse.args[1], 1);
IHandler handler = handlerOpt.get();
if (handler instanceof GlobalHandler)
throw new CommandException(Text.of("You may not delete the global handler!"));
|
1,276 |
.excludeCurrent(true)
.autoCloseQuotes(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
<BUG>return ImmutableList.of("region", "handler").stream()
.filter(new StartsWithPredicate(parse.current.token))</BUG>
.map(args -> parse.current.prefix + args)
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
.excludeCurrent(true)
.autoCloseQuotes(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
return Stream.of("region", "handler")
.filter(new StartsWithPredicate(parse.current.token))
.map(args -> parse.current.prefix + args)
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
1,277 |
.excludeCurrent(true)
.autoCloseQuotes(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
<BUG>return ImmutableList.of("region", "handler").stream()
.filter(new StartsWithPredicate(parse.current.token))</BUG>
.map(args -> parse.current.prefix + args)
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
.excludeCurrent(true)
.autoCloseQuotes(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
return Stream.of("region", "handler")
.filter(new StartsWithPredicate(parse.current.token))
.map(args -> parse.current.prefix + args)
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
1,278 |
.autoCloseQuotes(true)
.leaveFinalAsIs(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
<BUG>return ImmutableList.of("region", "worldregion", "handler", "controller").stream()
</BUG>
.filter(new StartsWithPredicate(parse.current.token))
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
.autoCloseQuotes(true)
.leaveFinalAsIs(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
return Stream.of("region", "worldregion", "handler", "controller")
.filter(new StartsWithPredicate(parse.current.token))
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index == 1) {
|
1,279 |
.excludeCurrent(true)
.autoCloseQuotes(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
<BUG>return ImmutableList.of("region", "handler").stream()
.filter(new StartsWithPredicate(parse.current.token))</BUG>
.map(args -> parse.current.prefix + args)
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index > 0) {
|
.excludeCurrent(true)
.autoCloseQuotes(true)
.parse();
if (parse.current.type.equals(AdvCmdParser.CurrentElement.ElementType.ARGUMENT)) {
if (parse.current.index == 0)
return Stream.of("region", "handler")
.filter(new StartsWithPredicate(parse.current.token))
.map(args -> parse.current.prefix + args)
.collect(GuavaCollectors.toImmutableList());
else if (parse.current.index > 0) {
|
1,280 |
@Dependency(id = "foxcore")
},
description = "A world protection plugin built for SpongeAPI. Requires FoxCore.",
authors = {"gravityfox"},
url = "https://github.com/FoxDenStudio/FoxGuard")
<BUG>public final class FoxGuardMain {
public final Cause pluginCause = Cause.builder().named("plugin", this).build();
private static FoxGuardMain instanceField;</BUG>
@Inject
private Logger logger;
|
@Dependency(id = "foxcore")
},
description = "A world protection plugin built for SpongeAPI. Requires FoxCore.",
authors = {"gravityfox"},
url = "https://github.com/FoxDenStudio/FoxGuard")
public final class FoxGuardMain {
private static FoxGuardMain instanceField;
public final Cause pluginCause = Cause.builder().named("plugin", this).build();
@Inject
private Logger logger;
|
1,281 |
private UserStorageService userStorage;
private EconomyService economyService = null;
private boolean loaded = false;
private FCCommandDispatcher fgDispatcher;
public static FoxGuardMain instance() {
<BUG>return instanceField;
}</BUG>
@Listener
public void construct(GameConstructionEvent event) {
instanceField = this;
|
private UserStorageService userStorage;
private EconomyService economyService = null;
private boolean loaded = false;
private FCCommandDispatcher fgDispatcher;
public static FoxGuardMain instance() {
return instanceField;
}
public static Cause getCause() {
return instance().pluginCause;
}
@Listener
public void construct(GameConstructionEvent event) {
instanceField = this;
|
1,282 |
return configDirectory;
}
public boolean isLoaded() {
return loaded;
}
<BUG>public static Cause getCause() {
return instance().pluginCause;
}</BUG>
public EconomyService getEconomyService() {
return economyService;
|
return configDirectory;
}
public boolean isLoaded() {
return loaded;
}
public EconomyService getEconomyService() {
return economyService;
|
1,283 |
import org.rajawali3d.materials.Material;
import org.rajawali3d.materials.methods.DiffuseMethod;
import org.rajawali3d.materials.textures.ATexture;
import org.rajawali3d.materials.textures.StreamingTexture;
import org.rajawali3d.materials.textures.Texture;
<BUG>import org.rajawali3d.math.Matrix4;
import org.rajawali3d.math.vector.Vector3;</BUG>
import org.rajawali3d.primitives.ScreenQuad;
import org.rajawali3d.primitives.Sphere;
import org.rajawali3d.renderer.RajawaliRenderer;
|
import org.rajawali3d.materials.Material;
import org.rajawali3d.materials.methods.DiffuseMethod;
import org.rajawali3d.materials.textures.ATexture;
import org.rajawali3d.materials.textures.StreamingTexture;
import org.rajawali3d.materials.textures.Texture;
import org.rajawali3d.math.Matrix4;
import org.rajawali3d.math.Quaternion;
import org.rajawali3d.math.vector.Vector3;
import org.rajawali3d.primitives.ScreenQuad;
import org.rajawali3d.primitives.Sphere;
import org.rajawali3d.renderer.RajawaliRenderer;
|
1,284 |
translationMoon.setRepeatMode(Animation.RepeatMode.INFINITE);
translationMoon.setTransformable3D(moon);
getCurrentScene().registerAnimation(translationMoon);
translationMoon.play();
}
<BUG>public void updateRenderCameraPose(TangoPoseData devicePose, DeviceExtrinsics extrinsics) {
Pose cameraPose = ScenePoseCalculator.toOpenGlCameraPose(devicePose, extrinsics);
getCurrentCamera().setRotation(cameraPose.getOrientation());
getCurrentCamera().setPosition(cameraPose.getPosition());
}</BUG>
public int getTextureId() {
|
translationMoon.setRepeatMode(Animation.RepeatMode.INFINITE);
translationMoon.setTransformable3D(moon);
getCurrentScene().registerAnimation(translationMoon);
translationMoon.play();
}
public void updateRenderCameraPose(TangoPoseData cameraPose) {
float[] rotation = cameraPose.getRotationAsFloats();
float[] translation = cameraPose.getTranslationAsFloats();
Quaternion quaternion = new Quaternion(rotation[3], rotation[0], rotation[1], rotation[2]);
getCurrentCamera().setRotation(quaternion.conjugate());
getCurrentCamera().setPosition(translation[0], translation[1], translation[2]);
}
public int getTextureId() {
|
1,285 |
package com.projecttango.examples.java.helloareadescription;
import com.google.atap.tangoservice.Tango;
<BUG>import com.google.atap.tangoservice.Tango.OnTangoUpdateListener;
import com.google.atap.tangoservice.TangoConfig;</BUG>
import com.google.atap.tangoservice.TangoCoordinateFramePair;
import com.google.atap.tangoservice.TangoErrorException;
import com.google.atap.tangoservice.TangoEvent;
|
package com.projecttango.examples.java.helloareadescription;
import com.google.atap.tangoservice.Tango;
import com.google.atap.tangoservice.Tango.OnTangoUpdateListener;
import com.google.atap.tangoservice.TangoAreaDescriptionMetaData;
import com.google.atap.tangoservice.TangoConfig;
import com.google.atap.tangoservice.TangoCoordinateFramePair;
import com.google.atap.tangoservice.TangoErrorException;
import com.google.atap.tangoservice.TangoEvent;
|
1,286 |
Toast.makeText(this, R.string.tango_not_ready, Toast.LENGTH_SHORT).show();
return;
}
Bundle bundle = new Bundle();
TangoAreaDescriptionMetaData metaData = mTango.loadAreaDescriptionMetaData(mCurrentUuid);
<BUG>byte[] adfNameBytes = metaData.get("name");
if (adfNameBytes != null) {</BUG>
String fillDialogName = new String(adfNameBytes);
<BUG>bundle.putString("name", fillDialogName);
}
bundle.putString("id", mCurrentUuid);
FragmentManager manager = getFragmentManager();</BUG>
SetAdfNameDialog setAdfNameDialog = new SetAdfNameDialog();
|
Toast.makeText(this, R.string.tango_not_ready, Toast.LENGTH_SHORT).show();
return;
}
Bundle bundle = new Bundle();
TangoAreaDescriptionMetaData metaData = mTango.loadAreaDescriptionMetaData(mCurrentUuid);
byte[] adfNameBytes = metaData.get(TangoAreaDescriptionMetaData.KEY_NAME);
if (adfNameBytes != null) {
String fillDialogName = new String(adfNameBytes);
bundle.putString(TangoAreaDescriptionMetaData.KEY_NAME, fillDialogName);
}
bundle.putString(TangoAreaDescriptionMetaData.KEY_UUID, mCurrentUuid);
FragmentManager manager = getFragmentManager();
SetAdfNameDialog setAdfNameDialog = new SetAdfNameDialog();
|
1,287 |
package com.projecttango.examples.java.augmentedreality;
import com.google.atap.tangoservice.Tango;
import com.google.atap.tangoservice.Tango.OnTangoUpdateListener;
import com.google.atap.tangoservice.TangoCameraIntrinsics;
import com.google.atap.tangoservice.TangoConfig;
<BUG>import com.google.atap.tangoservice.TangoCoordinateFramePair;
import com.google.atap.tangoservice.TangoEvent;</BUG>
import com.google.atap.tangoservice.TangoOutOfDateException;
import com.google.atap.tangoservice.TangoPoseData;
import com.google.atap.tangoservice.TangoXyzIjData;
|
package com.projecttango.examples.java.augmentedreality;
import com.google.atap.tangoservice.Tango;
import com.google.atap.tangoservice.Tango.OnTangoUpdateListener;
import com.google.atap.tangoservice.TangoCameraIntrinsics;
import com.google.atap.tangoservice.TangoConfig;
import com.google.atap.tangoservice.TangoCoordinateFramePair;
import com.google.atap.tangoservice.TangoErrorException;
import com.google.atap.tangoservice.TangoEvent;
import com.google.atap.tangoservice.TangoOutOfDateException;
import com.google.atap.tangoservice.TangoPoseData;
import com.google.atap.tangoservice.TangoXyzIjData;
|
1,288 |
super.onResume();
if (!mIsConnected) {
mTango = new Tango(AugmentedRealityActivity.this, new Runnable() {
@Override
public void run() {
<BUG>try {
connectTango();</BUG>
setupRenderer();
mIsConnected = true;
} catch (TangoOutOfDateException e) {
|
super.onResume();
if (!mIsConnected) {
mTango = new Tango(AugmentedRealityActivity.this, new Runnable() {
@Override
public void run() {
try {
TangoSupport.initialize();
connectTango();
setupRenderer();
mIsConnected = true;
} catch (TangoOutOfDateException e) {
|
1,289 |
if (lastFramePose.statusCode == TangoPoseData.POSE_VALID) {
mRenderer.updateRenderCameraPose(lastFramePose, mExtrinsics);
mCameraPoseTimestamp = lastFramePose.timestamp;</BUG>
} else {
<BUG>Log.w(TAG, "Can't get device pose at time: " + mRgbTimestampGlThread);
}</BUG>
}
}
}
@Override
|
if (lastFramePose.statusCode == TangoPoseData.POSE_VALID) {
mRenderer.updateRenderCameraPose(lastFramePose);
mCameraPoseTimestamp = lastFramePose.timestamp;
} else {
Log.w(TAG, "Can't get device pose at time: " +
mRgbTimestampGlThread);
}
}
}
}
@Override
|
1,290 |
private static FGStorageManager instance;
private final Logger logger = FoxGuardMain.instance().getLogger();</BUG>
private final Set<LoadEntry> loaded = new HashSet<>();
private final Path directory = getDirectory();
private final Map<String, Path> worldDirectories;
<BUG>private FGStorageManager() {
defaultModifiedMap = new CacheMap<>((k, m) -> {</BUG>
if (k instanceof IFGObject) {
m.put((IFGObject) k, true);
return true;
|
private static FGStorageManager instance;
public final HashMap<IFGObject, Boolean> defaultModifiedMap;
private final UserStorageService userStorageService;
private final Logger logger = FoxGuardMain.instance().getLogger();
private final Set<LoadEntry> loaded = new HashSet<>();
private final Path directory = getDirectory();
private final Map<String, Path> worldDirectories;
private FGStorageManager() {
userStorageService = FoxGuardMain.instance().getUserStorage();
defaultModifiedMap = new CacheMap<>((k, m) -> {
if (k instanceof IFGObject) {
m.put((IFGObject) k, true);
return true;
|
1,291 |
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving region \"" + name + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving region " + logName + "!", e);
}
logger.info("Saving metadata for region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,292 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
</BUG>
}
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + logName + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
|
1,293 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("Region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("Region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,294 |
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving world region \"" + name + "\" in world \"" + world.getName() + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for world region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving world region " + logName + " in world " + world.getName() + "!", e);
}
logger.info("Saving metadata for world region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,295 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
</BUG>
}
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + logName + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
|
1,296 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("World region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("World region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
1,297 |
String name = fgObject.getName();
Path singleDir = dir.resolve(name.toLowerCase());
</BUG>
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
<BUG>logger.info((shouldSave ? "S" : "Force s") + "aving handler \"" + name + "\" in directory: " + singleDir);
</BUG>
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
String name = fgObject.getName();
UUID owner = fgObject.getOwner();
boolean isOwned = !owner.equals(SERVER_UUID);
Optional<User> userOwner = userStorageService.get(owner);
String logName = (userOwner.isPresent() ? userOwner.get().getName() + ":" : "") + (isOwned ? owner + ":" : "") + name;
if (fgObject.autoSave()) {
Path singleDir = serverDir.resolve(name.toLowerCase());
boolean shouldSave = fgObject.shouldSave();
if (force || shouldSave) {
logger.info((shouldSave ? "S" : "Force s") + "aving handler " + logName + " in directory: " + singleDir);
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
|
1,298 |
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
<BUG>logger.error("There was an error while saving region \"" + name + "\"!", e);
</BUG>
}
<BUG>logger.info("Saving metadata for region \"" + name + "\"");
</BUG>
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
constructDirectory(singleDir);
try {
fgObject.save(singleDir);
} catch (Exception e) {
logger.error("There was an error while saving region " + logName + "!", e);
}
logger.info("Saving metadata for region " + logName);
try (DB metaDB = DBMaker.fileDB(singleDir.resolve("metadata.foxdb").normalize().toString()).make()) {
|
1,299 |
metaCategory.set(FGUtil.getCategory(fgObject));
<BUG>metaType.set(fgObject.getUniqueTypeString());
metaEnabled.set(fgObject.isEnabled());</BUG>
}
} else {
<BUG>logger.info("Region \"" + name + "\" is already up to date. Skipping...");
</BUG>
}
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
|
metaCategory.set(FGUtil.getCategory(fgObject));
metaType.set(fgObject.getUniqueTypeString());
metaOwner.set(owner);
metaEnabled.set(fgObject.isEnabled());
}
} else {
logger.info("Region " + logName + " is already up to date. Skipping...");
}
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
|
1,300 |
mainMap.put(name, FGUtil.getCategory(fgObject));
<BUG>typeMap.put(name, fgObject.getUniqueTypeString());
enabledMap.put(name, fgObject.isEnabled());</BUG>
defaultModifiedMap.put(fgObject, false);
} else {
<BUG>logger.info("Region " + fgObject.getName() + " does not need saving. Skipping...");
</BUG>
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
mainMap.put(name, FGUtil.getCategory(fgObject));
typeMap.put(name, fgObject.getUniqueTypeString());
ownerMap.put(name, owner);
enabledMap.put(name, fgObject.isEnabled());
defaultModifiedMap.put(fgObject, false);
} else {
logger.info("Region " + logName + " does not need saving. Skipping...");
}
if (fgObject.saveLinks()) {
linksMap.put(name, serializeHandlerList(fgObject.getHandlers()));
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.