repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksHostsFragment.java
|
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
|
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.HostsListAdapter;
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.model.Host;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment that shows a list of hosts.
*
*/
public class ChecksHostsFragment extends BaseServiceConnectedListFragment {
public static String TAG = ChecksHostsFragment.class.getSimpleName();
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
private boolean mLoadingSpinnerVisible = true;
|
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksHostsFragment.java
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.HostsListAdapter;
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.model.Host;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment that shows a list of hosts.
*
*/
public class ChecksHostsFragment extends BaseServiceConnectedListFragment {
public static String TAG = ChecksHostsFragment.class.getSimpleName();
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
private boolean mLoadingSpinnerVisible = true;
|
private OnChecksItemSelectedListener mCallbackMain;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/ScreensDetailsFragment.java
|
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnGraphsLoadedListener.java
// public interface OnGraphsLoadedListener {
//
// /**
// * Called when one or several graphs have been completely loaded.
// */
// public void onGraphsLoaded();
//
// /**
// * Called upon a loading progress update.
// *
// * @param progress
// * the current progress
// */
// public void onGraphsProgressUpdate(int progress);
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/model/Screen.java
// @DatabaseTable(tableName = "screens")
// public class Screen implements Comparable<Screen> {
//
// private static final String INDEX_SCREENID_HOST = "screen_host_idx";
// /** row ID */
// public static final String COLUMN_ID = "id";
// @DatabaseField(generatedId = true, columnName = COLUMN_ID)
// long id;
// /** Screen ID */
// public static final String COLUMN_SCREENID = "screenid";
// @DatabaseField(uniqueIndexName = INDEX_SCREENID_HOST, columnName = COLUMN_SCREENID)
// long screenId;
// /** Screen name */
// public static final String COLUMN_NAME = "name";
// @DatabaseField(columnName = COLUMN_NAME)
// String name;
//
// /** Host (needed for templates */
// public static final String COLUMN_HOST = "host";
// @DatabaseField(uniqueIndexName = INDEX_SCREENID_HOST, foreign = true, foreignAutoRefresh = true, columnName = COLUMN_HOST)
// Host host;
//
// /** zabbix server */
// public static final String COLUMN_ZABBIXSERVER_ID = "zabbixserverid";
// @DatabaseField(columnName = COLUMN_ZABBIXSERVER_ID)
// private Long zabbixServerId;
//
// Collection<Graph> graphs;
//
// public Screen() {
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public long getScreenId() {
// return screenId;
// }
//
// public String getName() {
// return name;
// }
//
// public Collection<Graph> getGraphs() {
// return graphs;
// }
//
// public void setGraphs(Collection<Graph> graphs) {
// this.graphs = graphs;
// }
//
// public void setScreenId(long screenId) {
// this.screenId = screenId;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public int compareTo(Screen another) {
// if (another.getScreenId() < screenId)
// return 1;
// if (another.getScreenId() > screenId)
// return -1;
// if(!another.getHost().equals(host))
// return -1;
// return 0;
// }
//
// public Long getZabbixServerId() {
// return zabbixServerId;
// }
//
// public void setZabbixServerId(Long zabbixServerId) {
// this.zabbixServerId = zabbixServerId;
// }
//
// public Host getHost() {
// return host;
// }
//
// public void setHost(Host host) {
// this.host = host;
// }
// }
|
import com.inovex.zabbixmobile.model.Graph;
import com.inovex.zabbixmobile.model.Screen;
import com.inovex.zabbixmobile.util.GraphUtil;
import com.jjoe64.graphview.LineGraphView;
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.listeners.OnGraphsLoadedListener;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing one particular screen.
*
*/
public class ScreensDetailsFragment extends BaseServiceConnectedFragment
implements OnGraphsLoadedListener {
private static final String ARG_GRAPH_SPINNER_VISIBLE = "arg_graph_spinner_visible";
|
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnGraphsLoadedListener.java
// public interface OnGraphsLoadedListener {
//
// /**
// * Called when one or several graphs have been completely loaded.
// */
// public void onGraphsLoaded();
//
// /**
// * Called upon a loading progress update.
// *
// * @param progress
// * the current progress
// */
// public void onGraphsProgressUpdate(int progress);
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/model/Screen.java
// @DatabaseTable(tableName = "screens")
// public class Screen implements Comparable<Screen> {
//
// private static final String INDEX_SCREENID_HOST = "screen_host_idx";
// /** row ID */
// public static final String COLUMN_ID = "id";
// @DatabaseField(generatedId = true, columnName = COLUMN_ID)
// long id;
// /** Screen ID */
// public static final String COLUMN_SCREENID = "screenid";
// @DatabaseField(uniqueIndexName = INDEX_SCREENID_HOST, columnName = COLUMN_SCREENID)
// long screenId;
// /** Screen name */
// public static final String COLUMN_NAME = "name";
// @DatabaseField(columnName = COLUMN_NAME)
// String name;
//
// /** Host (needed for templates */
// public static final String COLUMN_HOST = "host";
// @DatabaseField(uniqueIndexName = INDEX_SCREENID_HOST, foreign = true, foreignAutoRefresh = true, columnName = COLUMN_HOST)
// Host host;
//
// /** zabbix server */
// public static final String COLUMN_ZABBIXSERVER_ID = "zabbixserverid";
// @DatabaseField(columnName = COLUMN_ZABBIXSERVER_ID)
// private Long zabbixServerId;
//
// Collection<Graph> graphs;
//
// public Screen() {
// }
//
// public long getId() {
// return id;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public long getScreenId() {
// return screenId;
// }
//
// public String getName() {
// return name;
// }
//
// public Collection<Graph> getGraphs() {
// return graphs;
// }
//
// public void setGraphs(Collection<Graph> graphs) {
// this.graphs = graphs;
// }
//
// public void setScreenId(long screenId) {
// this.screenId = screenId;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public int compareTo(Screen another) {
// if (another.getScreenId() < screenId)
// return 1;
// if (another.getScreenId() > screenId)
// return -1;
// if(!another.getHost().equals(host))
// return -1;
// return 0;
// }
//
// public Long getZabbixServerId() {
// return zabbixServerId;
// }
//
// public void setZabbixServerId(Long zabbixServerId) {
// this.zabbixServerId = zabbixServerId;
// }
//
// public Host getHost() {
// return host;
// }
//
// public void setHost(Host host) {
// this.host = host;
// }
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/ScreensDetailsFragment.java
import com.inovex.zabbixmobile.model.Graph;
import com.inovex.zabbixmobile.model.Screen;
import com.inovex.zabbixmobile.util.GraphUtil;
import com.jjoe64.graphview.LineGraphView;
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.listeners.OnGraphsLoadedListener;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing one particular screen.
*
*/
public class ScreensDetailsFragment extends BaseServiceConnectedFragment
implements OnGraphsLoadedListener {
private static final String ARG_GRAPH_SPINNER_VISIBLE = "arg_graph_spinner_visible";
|
private Screen mScreen;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/ScreensListFragment.java
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ScreensListAdapter.java
// public class ScreensListAdapter extends BaseServiceAdapter<Screen> {
//
// private static final String TAG = ScreensListAdapter.class.getSimpleName();
// private int mTextViewResourceId = R.layout.list_item_screens;
//
// /**
// * Constructor.
// *
// * @param service
// */
// public ScreensListAdapter(ZabbixDataService service) {
// super(service);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View row = convertView;
//
// if (row == null) {
// row = getInflater().inflate(mTextViewResourceId, parent, false);
//
// }
//
// TextView title = (TextView) row.findViewById(R.id.screen_entry_name);
//
// Screen s = getItem(position);
//
// StringBuilder titleBuilder = new StringBuilder();
// if(s.getHost() != null) {
// titleBuilder.append(s.getHost().getName() + " - ");
// }
// titleBuilder.append(s.getName());
// title.setText(titleBuilder.toString());
//
// return row;
// }
//
// @Override
// public long getItemId(int position) {
// Screen item = getItem(position);
// if (item != null)
// return item.getScreenId();
// return 0;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnScreensItemSelectedListener.java
// public interface OnScreensItemSelectedListener {
//
// /**
// * Callback method for the selection of a screen.
// *
// * @param screen
// * the screen
// */
// public void onScreenSelected(Screen screen);
//
// }
|
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ScreensListAdapter;
import com.inovex.zabbixmobile.listeners.OnScreensItemSelectedListener;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing a list of all screens specified in Zabbix.
*
*/
public class ScreensListFragment extends BaseServiceConnectedListFragment {
public static String TAG = ScreensListFragment.class.getSimpleName();
private static final String ARG_POSITION = "arg_position";
private static final String ARG_ITEM_ID = "arg_item_id";
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
private int mCurrentPosition = 0;
private long mCurrentItemId = 0;
private boolean mLoadingSpinnerVisible = true;
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ScreensListAdapter.java
// public class ScreensListAdapter extends BaseServiceAdapter<Screen> {
//
// private static final String TAG = ScreensListAdapter.class.getSimpleName();
// private int mTextViewResourceId = R.layout.list_item_screens;
//
// /**
// * Constructor.
// *
// * @param service
// */
// public ScreensListAdapter(ZabbixDataService service) {
// super(service);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View row = convertView;
//
// if (row == null) {
// row = getInflater().inflate(mTextViewResourceId, parent, false);
//
// }
//
// TextView title = (TextView) row.findViewById(R.id.screen_entry_name);
//
// Screen s = getItem(position);
//
// StringBuilder titleBuilder = new StringBuilder();
// if(s.getHost() != null) {
// titleBuilder.append(s.getHost().getName() + " - ");
// }
// titleBuilder.append(s.getName());
// title.setText(titleBuilder.toString());
//
// return row;
// }
//
// @Override
// public long getItemId(int position) {
// Screen item = getItem(position);
// if (item != null)
// return item.getScreenId();
// return 0;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnScreensItemSelectedListener.java
// public interface OnScreensItemSelectedListener {
//
// /**
// * Callback method for the selection of a screen.
// *
// * @param screen
// * the screen
// */
// public void onScreenSelected(Screen screen);
//
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/ScreensListFragment.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ScreensListAdapter;
import com.inovex.zabbixmobile.listeners.OnScreensItemSelectedListener;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing a list of all screens specified in Zabbix.
*
*/
public class ScreensListFragment extends BaseServiceConnectedListFragment {
public static String TAG = ScreensListFragment.class.getSimpleName();
private static final String ARG_POSITION = "arg_position";
private static final String ARG_ITEM_ID = "arg_item_id";
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
private int mCurrentPosition = 0;
private long mCurrentItemId = 0;
private boolean mLoadingSpinnerVisible = true;
|
private OnScreensItemSelectedListener mCallbackMain;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/ScreensListFragment.java
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ScreensListAdapter.java
// public class ScreensListAdapter extends BaseServiceAdapter<Screen> {
//
// private static final String TAG = ScreensListAdapter.class.getSimpleName();
// private int mTextViewResourceId = R.layout.list_item_screens;
//
// /**
// * Constructor.
// *
// * @param service
// */
// public ScreensListAdapter(ZabbixDataService service) {
// super(service);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View row = convertView;
//
// if (row == null) {
// row = getInflater().inflate(mTextViewResourceId, parent, false);
//
// }
//
// TextView title = (TextView) row.findViewById(R.id.screen_entry_name);
//
// Screen s = getItem(position);
//
// StringBuilder titleBuilder = new StringBuilder();
// if(s.getHost() != null) {
// titleBuilder.append(s.getHost().getName() + " - ");
// }
// titleBuilder.append(s.getName());
// title.setText(titleBuilder.toString());
//
// return row;
// }
//
// @Override
// public long getItemId(int position) {
// Screen item = getItem(position);
// if (item != null)
// return item.getScreenId();
// return 0;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnScreensItemSelectedListener.java
// public interface OnScreensItemSelectedListener {
//
// /**
// * Callback method for the selection of a screen.
// *
// * @param screen
// * the screen
// */
// public void onScreenSelected(Screen screen);
//
// }
|
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ScreensListAdapter;
import com.inovex.zabbixmobile.listeners.OnScreensItemSelectedListener;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing a list of all screens specified in Zabbix.
*
*/
public class ScreensListFragment extends BaseServiceConnectedListFragment {
public static String TAG = ScreensListFragment.class.getSimpleName();
private static final String ARG_POSITION = "arg_position";
private static final String ARG_ITEM_ID = "arg_item_id";
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
private int mCurrentPosition = 0;
private long mCurrentItemId = 0;
private boolean mLoadingSpinnerVisible = true;
private OnScreensItemSelectedListener mCallbackMain;
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ScreensListAdapter.java
// public class ScreensListAdapter extends BaseServiceAdapter<Screen> {
//
// private static final String TAG = ScreensListAdapter.class.getSimpleName();
// private int mTextViewResourceId = R.layout.list_item_screens;
//
// /**
// * Constructor.
// *
// * @param service
// */
// public ScreensListAdapter(ZabbixDataService service) {
// super(service);
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View row = convertView;
//
// if (row == null) {
// row = getInflater().inflate(mTextViewResourceId, parent, false);
//
// }
//
// TextView title = (TextView) row.findViewById(R.id.screen_entry_name);
//
// Screen s = getItem(position);
//
// StringBuilder titleBuilder = new StringBuilder();
// if(s.getHost() != null) {
// titleBuilder.append(s.getHost().getName() + " - ");
// }
// titleBuilder.append(s.getName());
// title.setText(titleBuilder.toString());
//
// return row;
// }
//
// @Override
// public long getItemId(int position) {
// Screen item = getItem(position);
// if (item != null)
// return item.getScreenId();
// return 0;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnScreensItemSelectedListener.java
// public interface OnScreensItemSelectedListener {
//
// /**
// * Callback method for the selection of a screen.
// *
// * @param screen
// * the screen
// */
// public void onScreenSelected(Screen screen);
//
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/ScreensListFragment.java
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListView;
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ScreensListAdapter;
import com.inovex.zabbixmobile.listeners.OnScreensItemSelectedListener;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing a list of all screens specified in Zabbix.
*
*/
public class ScreensListFragment extends BaseServiceConnectedListFragment {
public static String TAG = ScreensListFragment.class.getSimpleName();
private static final String ARG_POSITION = "arg_position";
private static final String ARG_ITEM_ID = "arg_item_id";
private static final String ARG_SPINNER_VISIBLE = "arg_spinner_visible";
private int mCurrentPosition = 0;
private long mCurrentItemId = 0;
private boolean mLoadingSpinnerVisible = true;
private OnScreensItemSelectedListener mCallbackMain;
|
private ScreensListAdapter mListAdapter;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksApplicationsFragment.java
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ChecksApplicationsPagerAdapter.java
// public class ChecksApplicationsPagerAdapter extends
// BaseServicePagerAdapter<Application> {
//
// private static final String TAG = ChecksApplicationsPagerAdapter.class
// .getSimpleName();
//
// @Override
// public CharSequence getPageTitle(int position) {
// Application application = getObject(position);
// if(application != null){
// return application.getName();
// } else {
// return "";
// }
// }
//
// @Override
// public Long getItemId(int position) {
// if (getObject(position) == null)
// return null;
// return getObject(position).getId();
// }
//
// @Override
// protected Fragment getItem(int position) {
// ChecksApplicationsPage p = new ChecksApplicationsPage();
// Bundle args = new Bundle();
// args.putLong("applicationID",getObject(position).getId());
// p.setArguments(args);
// return p;
// }
//
// @Override
// public int getItemPosition(Object object) {
// // This prevents caching of fragments. We need to disable caching
// // because we have only one adapter which is reused when another host is
// // selected.
// return POSITION_NONE;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
|
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ChecksApplicationsPagerAdapter;
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.listeners.OnItemsLoadedListener;
import com.inovex.zabbixmobile.model.Host;
import android.app.Activity;
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing the applications of a particular host.
*
* In particular, this includes a view pager with one page for each application.
* Each page contains a list of items.
*
*/
public class ChecksApplicationsFragment extends BaseServiceConnectedFragment
implements OnItemsLoadedListener {
public static final String TAG = ChecksApplicationsFragment.class
.getSimpleName();
private Host mHost;
private boolean mApplicationsProgressBarVisible = true;
private boolean mItemsLoadingSpinnerVisible = true;
private static final String ARG_APPLICATIONS_SPINNER_VISIBLE = "arg_applications_spinner_visible";
private static final String ARG_ITEMS_SPINNER_VISIBLE = "arg_items_spinner_visible";
private TextView mTitleView;
protected ViewPager mApplicationsPager;
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ChecksApplicationsPagerAdapter.java
// public class ChecksApplicationsPagerAdapter extends
// BaseServicePagerAdapter<Application> {
//
// private static final String TAG = ChecksApplicationsPagerAdapter.class
// .getSimpleName();
//
// @Override
// public CharSequence getPageTitle(int position) {
// Application application = getObject(position);
// if(application != null){
// return application.getName();
// } else {
// return "";
// }
// }
//
// @Override
// public Long getItemId(int position) {
// if (getObject(position) == null)
// return null;
// return getObject(position).getId();
// }
//
// @Override
// protected Fragment getItem(int position) {
// ChecksApplicationsPage p = new ChecksApplicationsPage();
// Bundle args = new Bundle();
// args.putLong("applicationID",getObject(position).getId());
// p.setArguments(args);
// return p;
// }
//
// @Override
// public int getItemPosition(Object object) {
// // This prevents caching of fragments. We need to disable caching
// // because we have only one adapter which is reused when another host is
// // selected.
// return POSITION_NONE;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksApplicationsFragment.java
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ChecksApplicationsPagerAdapter;
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.listeners.OnItemsLoadedListener;
import com.inovex.zabbixmobile.model.Host;
import android.app.Activity;
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing the applications of a particular host.
*
* In particular, this includes a view pager with one page for each application.
* Each page contains a list of items.
*
*/
public class ChecksApplicationsFragment extends BaseServiceConnectedFragment
implements OnItemsLoadedListener {
public static final String TAG = ChecksApplicationsFragment.class
.getSimpleName();
private Host mHost;
private boolean mApplicationsProgressBarVisible = true;
private boolean mItemsLoadingSpinnerVisible = true;
private static final String ARG_APPLICATIONS_SPINNER_VISIBLE = "arg_applications_spinner_visible";
private static final String ARG_ITEMS_SPINNER_VISIBLE = "arg_items_spinner_visible";
private TextView mTitleView;
protected ViewPager mApplicationsPager;
|
protected ChecksApplicationsPagerAdapter mApplicationsPagerAdapter;
|
inovex/zax
|
src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksApplicationsFragment.java
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ChecksApplicationsPagerAdapter.java
// public class ChecksApplicationsPagerAdapter extends
// BaseServicePagerAdapter<Application> {
//
// private static final String TAG = ChecksApplicationsPagerAdapter.class
// .getSimpleName();
//
// @Override
// public CharSequence getPageTitle(int position) {
// Application application = getObject(position);
// if(application != null){
// return application.getName();
// } else {
// return "";
// }
// }
//
// @Override
// public Long getItemId(int position) {
// if (getObject(position) == null)
// return null;
// return getObject(position).getId();
// }
//
// @Override
// protected Fragment getItem(int position) {
// ChecksApplicationsPage p = new ChecksApplicationsPage();
// Bundle args = new Bundle();
// args.putLong("applicationID",getObject(position).getId());
// p.setArguments(args);
// return p;
// }
//
// @Override
// public int getItemPosition(Object object) {
// // This prevents caching of fragments. We need to disable caching
// // because we have only one adapter which is reused when another host is
// // selected.
// return POSITION_NONE;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
|
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ChecksApplicationsPagerAdapter;
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.listeners.OnItemsLoadedListener;
import com.inovex.zabbixmobile.model.Host;
import android.app.Activity;
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
|
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing the applications of a particular host.
*
* In particular, this includes a view pager with one page for each application.
* Each page contains a list of items.
*
*/
public class ChecksApplicationsFragment extends BaseServiceConnectedFragment
implements OnItemsLoadedListener {
public static final String TAG = ChecksApplicationsFragment.class
.getSimpleName();
private Host mHost;
private boolean mApplicationsProgressBarVisible = true;
private boolean mItemsLoadingSpinnerVisible = true;
private static final String ARG_APPLICATIONS_SPINNER_VISIBLE = "arg_applications_spinner_visible";
private static final String ARG_ITEMS_SPINNER_VISIBLE = "arg_items_spinner_visible";
private TextView mTitleView;
protected ViewPager mApplicationsPager;
protected ChecksApplicationsPagerAdapter mApplicationsPagerAdapter;
|
// Path: src/main/java/com/inovex/zabbixmobile/adapters/ChecksApplicationsPagerAdapter.java
// public class ChecksApplicationsPagerAdapter extends
// BaseServicePagerAdapter<Application> {
//
// private static final String TAG = ChecksApplicationsPagerAdapter.class
// .getSimpleName();
//
// @Override
// public CharSequence getPageTitle(int position) {
// Application application = getObject(position);
// if(application != null){
// return application.getName();
// } else {
// return "";
// }
// }
//
// @Override
// public Long getItemId(int position) {
// if (getObject(position) == null)
// return null;
// return getObject(position).getId();
// }
//
// @Override
// protected Fragment getItem(int position) {
// ChecksApplicationsPage p = new ChecksApplicationsPage();
// Bundle args = new Bundle();
// args.putLong("applicationID",getObject(position).getId());
// p.setArguments(args);
// return p;
// }
//
// @Override
// public int getItemPosition(Object object) {
// // This prevents caching of fragments. We need to disable caching
// // because we have only one adapter which is reused when another host is
// // selected.
// return POSITION_NONE;
// }
//
// }
//
// Path: src/main/java/com/inovex/zabbixmobile/listeners/OnChecksItemSelectedListener.java
// public interface OnChecksItemSelectedListener {
//
// /**
// * Callback method for the selection of a host.
// *
// * @param position
// * list position
// * @param id
// * event ID (Zabbix event_id)
// */
// public void onHostSelected(int position, long id);
//
// /**
// * Callback method for the selection of an application.
// *
// * @param position
// * list position
// */
// public void onApplicationSelected(int position);
//
// /**
// * Callback method for the selection of an item.
// *
// * @param position
// * list position
// * @param item
// * the selected item
// * @param showItemDetails
// * whether or not the item details shall be shown (at activity
// * startup, the details shall not be shown)
// */
// public void onItemSelected(int position, Item item, boolean showItemDetails);
//
// }
// Path: src/main/java/com/inovex/zabbixmobile/activities/fragments/ChecksApplicationsFragment.java
import com.inovex.zabbixmobile.R;
import com.inovex.zabbixmobile.adapters.ChecksApplicationsPagerAdapter;
import com.inovex.zabbixmobile.listeners.OnChecksItemSelectedListener;
import com.inovex.zabbixmobile.listeners.OnItemsLoadedListener;
import com.inovex.zabbixmobile.model.Host;
import android.app.Activity;
import android.content.ComponentName;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
/*
This file is part of ZAX.
ZAX is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZAX is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZAX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.inovex.zabbixmobile.activities.fragments;
/**
* Fragment showing the applications of a particular host.
*
* In particular, this includes a view pager with one page for each application.
* Each page contains a list of items.
*
*/
public class ChecksApplicationsFragment extends BaseServiceConnectedFragment
implements OnItemsLoadedListener {
public static final String TAG = ChecksApplicationsFragment.class
.getSimpleName();
private Host mHost;
private boolean mApplicationsProgressBarVisible = true;
private boolean mItemsLoadingSpinnerVisible = true;
private static final String ARG_APPLICATIONS_SPINNER_VISIBLE = "arg_applications_spinner_visible";
private static final String ARG_ITEMS_SPINNER_VISIBLE = "arg_items_spinner_visible";
private TextView mTitleView;
protected ViewPager mApplicationsPager;
protected ChecksApplicationsPagerAdapter mApplicationsPagerAdapter;
|
private OnChecksItemSelectedListener mCallbackMain;
|
wayfinder/Wayfinder-Android-Locate
|
src/com/vodafone/locate/dialog/AlertDialog.java
|
// Path: src/com/vodafone/locate/view/ProgressBar.java
// public class ProgressBar extends ImageView {
//
// private boolean mAttached;
//
// public ProgressBar(Context context, AttributeSet attrs, int defStyle) {
// super(context, attrs, defStyle);
// this.init(context);
// }
//
// public ProgressBar(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.init(context);
// }
//
// public ProgressBar(Context context) {
// super(context);
// this.init(context);
// }
//
// private void init(Context context) {
// setImageResource(R.drawable.progress_bar);
// }
//
// public void setImage(int imageId) {
// setImageResource(imageId);
// setVisibility(VISIBLE);
// }
//
// @Override
// public void setVisibility(int visibility) {
// super.setVisibility(visibility);
// if(mAttached) {
// AnimationDrawable animationDrawable = (AnimationDrawable) getDrawable();
// if (animationDrawable != null) {
// if (getVisibility() == VISIBLE) {
// animationDrawable.start();
// } else {
// animationDrawable.stop();
// }
// }
// }
// }
//
// @Override
// protected void onAttachedToWindow() {
// super.onAttachedToWindow();
// mAttached = true;
// if (getVisibility() == VISIBLE) {
// AnimationDrawable animationDrawable = (AnimationDrawable) getDrawable();
// if (animationDrawable != null) {
// animationDrawable.start();
// }
// }
// }
//
// @Override
// protected void onDetachedFromWindow() {
// super.onDetachedFromWindow();
// mAttached = false;
// AnimationDrawable animationDrawable = (AnimationDrawable) getDrawable();
// if (animationDrawable != null) {
// animationDrawable.stop();
// }
// }
// }
|
import java.util.Timer;
import java.util.TimerTask;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.vodafone.locate.R;
import com.vodafone.locate.view.ProgressBar;
|
/*******************************************************************************
* Copyright (c) 1999-2010, Vodafone Group Services
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Vodafone Group Services nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
******************************************************************************/
package com.vodafone.locate.dialog;
public class AlertDialog extends Dialog {
private static Timer timer;
private TextView messageView;
private TextView secondaryMessageView;
private Button btnPos;
private Button btnNeu;
private Button btnNeg;
private LinearLayout contentView;
|
// Path: src/com/vodafone/locate/view/ProgressBar.java
// public class ProgressBar extends ImageView {
//
// private boolean mAttached;
//
// public ProgressBar(Context context, AttributeSet attrs, int defStyle) {
// super(context, attrs, defStyle);
// this.init(context);
// }
//
// public ProgressBar(Context context, AttributeSet attrs) {
// super(context, attrs);
// this.init(context);
// }
//
// public ProgressBar(Context context) {
// super(context);
// this.init(context);
// }
//
// private void init(Context context) {
// setImageResource(R.drawable.progress_bar);
// }
//
// public void setImage(int imageId) {
// setImageResource(imageId);
// setVisibility(VISIBLE);
// }
//
// @Override
// public void setVisibility(int visibility) {
// super.setVisibility(visibility);
// if(mAttached) {
// AnimationDrawable animationDrawable = (AnimationDrawable) getDrawable();
// if (animationDrawable != null) {
// if (getVisibility() == VISIBLE) {
// animationDrawable.start();
// } else {
// animationDrawable.stop();
// }
// }
// }
// }
//
// @Override
// protected void onAttachedToWindow() {
// super.onAttachedToWindow();
// mAttached = true;
// if (getVisibility() == VISIBLE) {
// AnimationDrawable animationDrawable = (AnimationDrawable) getDrawable();
// if (animationDrawable != null) {
// animationDrawable.start();
// }
// }
// }
//
// @Override
// protected void onDetachedFromWindow() {
// super.onDetachedFromWindow();
// mAttached = false;
// AnimationDrawable animationDrawable = (AnimationDrawable) getDrawable();
// if (animationDrawable != null) {
// animationDrawable.stop();
// }
// }
// }
// Path: src/com/vodafone/locate/dialog/AlertDialog.java
import java.util.Timer;
import java.util.TimerTask;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.vodafone.locate.R;
import com.vodafone.locate.view.ProgressBar;
/*******************************************************************************
* Copyright (c) 1999-2010, Vodafone Group Services
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Vodafone Group Services nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
******************************************************************************/
package com.vodafone.locate.dialog;
public class AlertDialog extends Dialog {
private static Timer timer;
private TextView messageView;
private TextView secondaryMessageView;
private Button btnPos;
private Button btnNeu;
private Button btnNeg;
private LinearLayout contentView;
|
private ProgressBar progressbar;
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/database/DatabaseHelper.java
|
// Path: src/main/java/com/github/otbproject/otbproject/command/scheduler/SchedulerFields.java
// public class SchedulerFields {
// public static final String COMMAND = "command";
// public static final String TYPE = "type";
// public static final String OFFSET = "offset";
// public static final String PERIOD = "period";
// public static final String RESET = "reset";
//
// public static final String TABLE_NAME = "tblSchedule";
// static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
//
// static {
// PRIMARY_KEYS.add(COMMAND);
// }
//
// private SchedulerFields() {}
//
// public static TableFields getTableFields() {
// HashMap<String, String> fields = new HashMap<>();
// fields.put(COMMAND, DataTypes.STRING);
// fields.put(TYPE, DataTypes.STRING);
// fields.put(OFFSET, DataTypes.INTEGER);
// fields.put(PERIOD, DataTypes.INTEGER);
// fields.put(RESET, DataTypes.STRING);
// return new TableFields(fields, PRIMARY_KEYS);
// }
// }
|
import com.github.otbproject.otbproject.command.AliasFields;
import com.github.otbproject.otbproject.command.CommandFields;
import com.github.otbproject.otbproject.command.scheduler.SchedulerFields;
import com.github.otbproject.otbproject.quote.QuoteFields;
import com.github.otbproject.otbproject.user.UserFields;
import java.util.HashMap;
|
package com.github.otbproject.otbproject.database;
public class DatabaseHelper {
private DatabaseHelper() {}
/**
* @return a HashMap used to create all the tables by the DatabaseWrapper.
* Tables are hard-coded into the method.
*/
public static HashMap<String, TableFields> getMainTablesHashMap() {
HashMap<String, TableFields> tables = new HashMap<>();
tables.put(CommandFields.TABLE_NAME, CommandFields.getTableFields());
tables.put(AliasFields.TABLE_NAME, AliasFields.getTableFields());
tables.put(UserFields.TABLE_NAME, UserFields.getTableFields());
|
// Path: src/main/java/com/github/otbproject/otbproject/command/scheduler/SchedulerFields.java
// public class SchedulerFields {
// public static final String COMMAND = "command";
// public static final String TYPE = "type";
// public static final String OFFSET = "offset";
// public static final String PERIOD = "period";
// public static final String RESET = "reset";
//
// public static final String TABLE_NAME = "tblSchedule";
// static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
//
// static {
// PRIMARY_KEYS.add(COMMAND);
// }
//
// private SchedulerFields() {}
//
// public static TableFields getTableFields() {
// HashMap<String, String> fields = new HashMap<>();
// fields.put(COMMAND, DataTypes.STRING);
// fields.put(TYPE, DataTypes.STRING);
// fields.put(OFFSET, DataTypes.INTEGER);
// fields.put(PERIOD, DataTypes.INTEGER);
// fields.put(RESET, DataTypes.STRING);
// return new TableFields(fields, PRIMARY_KEYS);
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/database/DatabaseHelper.java
import com.github.otbproject.otbproject.command.AliasFields;
import com.github.otbproject.otbproject.command.CommandFields;
import com.github.otbproject.otbproject.command.scheduler.SchedulerFields;
import com.github.otbproject.otbproject.quote.QuoteFields;
import com.github.otbproject.otbproject.user.UserFields;
import java.util.HashMap;
package com.github.otbproject.otbproject.database;
public class DatabaseHelper {
private DatabaseHelper() {}
/**
* @return a HashMap used to create all the tables by the DatabaseWrapper.
* Tables are hard-coded into the method.
*/
public static HashMap<String, TableFields> getMainTablesHashMap() {
HashMap<String, TableFields> tables = new HashMap<>();
tables.put(CommandFields.TABLE_NAME, CommandFields.getTableFields());
tables.put(AliasFields.TABLE_NAME, AliasFields.getTableFields());
tables.put(UserFields.TABLE_NAME, UserFields.getTableFields());
|
tables.put(SchedulerFields.TABLE_NAME, SchedulerFields.getTableFields());
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/filter/FilterGroupFields.java
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
|
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
|
package com.github.otbproject.otbproject.filter;
public class FilterGroupFields {
public static final String NAME = "name";
public static final String RESPONSE_COMMAND = "responseCmd";
public static final String USER_LEVEL = "userLevel";
public static final String ENABLED = "enabled";
public static final String TABLE_NAME = "tblFilterGroups";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(NAME);
}
private FilterGroupFields() {}
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/filter/FilterGroupFields.java
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
package com.github.otbproject.otbproject.filter;
public class FilterGroupFields {
public static final String NAME = "name";
public static final String RESPONSE_COMMAND = "responseCmd";
public static final String USER_LEVEL = "userLevel";
public static final String ENABLED = "enabled";
public static final String TABLE_NAME = "tblFilterGroups";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(NAME);
}
private FilterGroupFields() {}
|
public static TableFields getTableFields() {
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/filter/FilterGroupFields.java
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
|
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
|
package com.github.otbproject.otbproject.filter;
public class FilterGroupFields {
public static final String NAME = "name";
public static final String RESPONSE_COMMAND = "responseCmd";
public static final String USER_LEVEL = "userLevel";
public static final String ENABLED = "enabled";
public static final String TABLE_NAME = "tblFilterGroups";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(NAME);
}
private FilterGroupFields() {}
public static TableFields getTableFields() {
HashMap<String, String> map = new HashMap<>();
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/filter/FilterGroupFields.java
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
package com.github.otbproject.otbproject.filter;
public class FilterGroupFields {
public static final String NAME = "name";
public static final String RESPONSE_COMMAND = "responseCmd";
public static final String USER_LEVEL = "userLevel";
public static final String ENABLED = "enabled";
public static final String TABLE_NAME = "tblFilterGroups";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(NAME);
}
private FilterGroupFields() {}
public static TableFields getTableFields() {
HashMap<String, String> map = new HashMap<>();
|
map.put(NAME, DataTypes.STRING);
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/command/Alias.java
|
// Path: src/main/java/com/github/otbproject/otbproject/user/UserLevel.java
// public enum UserLevel {
// IGNORED(-10), DEFAULT(0), SUBSCRIBER(5), REGULAR(10), MODERATOR(20), SUPER_MODERATOR(30), BROADCASTER(40), INTERNAL(50), TOO_HIGH(200);
//
// private final int value;
//
// UserLevel(int userLevel) {
// this.value = userLevel;
// }
//
// public int getValue() {
// return value;
// }
// }
|
import com.github.otbproject.otbproject.user.UserLevel;
import javax.validation.constraints.NotNull;
|
package com.github.otbproject.otbproject.command;
public class Alias {
@NotNull
private String name;
@NotNull
private String command;
|
// Path: src/main/java/com/github/otbproject/otbproject/user/UserLevel.java
// public enum UserLevel {
// IGNORED(-10), DEFAULT(0), SUBSCRIBER(5), REGULAR(10), MODERATOR(20), SUPER_MODERATOR(30), BROADCASTER(40), INTERNAL(50), TOO_HIGH(200);
//
// private final int value;
//
// UserLevel(int userLevel) {
// this.value = userLevel;
// }
//
// public int getValue() {
// return value;
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/command/Alias.java
import com.github.otbproject.otbproject.user.UserLevel;
import javax.validation.constraints.NotNull;
package com.github.otbproject.otbproject.command;
public class Alias {
@NotNull
private String name;
@NotNull
private String command;
|
private UserLevel modifyingUserLevel = UserLevel.DEFAULT;
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/command/scheduler/Scheduler.java
|
// Path: src/main/java/com/github/otbproject/otbproject/util/ThreadUtil.java
// public class ThreadUtil {
// public static final Thread.UncaughtExceptionHandler UNCAUGHT_EXCEPTION_HANDLER;
//
// private ThreadUtil() {}
//
// static {
// UNCAUGHT_EXCEPTION_HANDLER = (t, e) -> {
// App.logger.error("Thread crashed: " + t.getName());
// App.logger.catching(e);
// Watcher.logException();
// };
// Thread.setDefaultUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER);
// }
//
// public static ExecutorService newSingleThreadExecutor() {
// return Executors.newSingleThreadExecutor(newThreadFactory());
// }
//
// public static ExecutorService newSingleThreadExecutor(String nameFormat) {
// return Executors.newSingleThreadExecutor(newThreadFactory(nameFormat));
// }
//
// public static ExecutorService newCachedThreadPool() {
// return Executors.newCachedThreadPool(newThreadFactory());
// }
//
// public static ExecutorService newCachedThreadPool(String nameFormat) {
// return Executors.newCachedThreadPool(newThreadFactory(nameFormat));
// }
//
// public static ThreadFactory newThreadFactory() {
// return new ThreadFactoryBuilder()
// .setUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER)
// .build();
// }
//
// public static ThreadFactory newThreadFactory(String nameFormat) {
// return new ThreadFactoryBuilder()
// .setNameFormat(nameFormat)
// .setUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER)
// .build();
// }
//
// public static void interruptIfInterruptedException(Exception e) {
// if (e instanceof InterruptedException) {
// Thread.currentThread().interrupt();
// }
// }
// }
|
import com.github.otbproject.otbproject.util.ThreadUtil;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
package com.github.otbproject.otbproject.command.scheduler;
public class Scheduler {
private ScheduledExecutorService scheduledExecutorService;
private volatile boolean running;
private final ReadWriteLock lock = new ReentrantReadWriteLock(true);
private final String channel;
public Scheduler(String channel) {
this.channel = channel;
}
private ScheduledExecutorService getService() {
|
// Path: src/main/java/com/github/otbproject/otbproject/util/ThreadUtil.java
// public class ThreadUtil {
// public static final Thread.UncaughtExceptionHandler UNCAUGHT_EXCEPTION_HANDLER;
//
// private ThreadUtil() {}
//
// static {
// UNCAUGHT_EXCEPTION_HANDLER = (t, e) -> {
// App.logger.error("Thread crashed: " + t.getName());
// App.logger.catching(e);
// Watcher.logException();
// };
// Thread.setDefaultUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER);
// }
//
// public static ExecutorService newSingleThreadExecutor() {
// return Executors.newSingleThreadExecutor(newThreadFactory());
// }
//
// public static ExecutorService newSingleThreadExecutor(String nameFormat) {
// return Executors.newSingleThreadExecutor(newThreadFactory(nameFormat));
// }
//
// public static ExecutorService newCachedThreadPool() {
// return Executors.newCachedThreadPool(newThreadFactory());
// }
//
// public static ExecutorService newCachedThreadPool(String nameFormat) {
// return Executors.newCachedThreadPool(newThreadFactory(nameFormat));
// }
//
// public static ThreadFactory newThreadFactory() {
// return new ThreadFactoryBuilder()
// .setUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER)
// .build();
// }
//
// public static ThreadFactory newThreadFactory(String nameFormat) {
// return new ThreadFactoryBuilder()
// .setNameFormat(nameFormat)
// .setUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER)
// .build();
// }
//
// public static void interruptIfInterruptedException(Exception e) {
// if (e instanceof InterruptedException) {
// Thread.currentThread().interrupt();
// }
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/command/scheduler/Scheduler.java
import com.github.otbproject.otbproject.util.ThreadUtil;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
package com.github.otbproject.otbproject.command.scheduler;
public class Scheduler {
private ScheduledExecutorService scheduledExecutorService;
private volatile boolean running;
private final ReadWriteLock lock = new ReentrantReadWriteLock(true);
private final String channel;
public Scheduler(String channel) {
this.channel = channel;
}
private ScheduledExecutorService getService() {
|
return Executors.newSingleThreadScheduledExecutor(ThreadUtil.newThreadFactory(channel + "-scheduler"));
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/channel/Channels.java
|
// Path: src/main/java/com/github/otbproject/otbproject/bot/Control.java
// public class Control {
// private static volatile boolean firstStart = true;
// private static volatile boolean running = false;
// private static volatile Bot bot = NullBot.INSTANCE;
//
// private Control() {}
//
// public static Bot bot() {
// return bot;
// }
//
// /**
// * Sets the bot to the given value. Fails if bot is running.
// *
// * @param bot A {@link Bot} to set as the bot
// * @return {@code true} if successfully set new value for bot
// */
// public static synchronized boolean setBot(Bot bot) {
// if (running) {
// return false;
// }
// Control.bot = bot;
// return true;
// }
//
// /**
// * Restarts the bot. Works whether or not bot is currently running.
// *
// * @return {@code true} if bot started successfully, {@code false} if it failed to start
// */
// public static synchronized boolean restart() {
// shutdown(true);
// try {
// return startup();
// } catch (StartupException e) {
// App.logger.catching(e);
// return false;
// }
// }
//
// /**
// * Does what it says on the tin
// */
// public static void shutdownAndExit() {
// shutdown(false);
// App.logger.info("Process stopped");
// System.exit(0);
// }
//
// /**
// * Stops the bot and cleans up anything which needs to be cleaned up
// * before the bot is started again
// *
// * @param cleanup whether or not to cleanup various data with the
// * expectation that the bot will be started again
// */
// public static synchronized boolean shutdown(boolean cleanup) {
// if (!running) {
// return false;
// }
//
// App.logger.info("Shutting down bot");
// Bot oldBot = bot;
// bot = NullBot.INSTANCE; // Quickly make calls to getBot() return NullBot
// oldBot.shutdown();
// if (cleanup) {
// shutdownCleanup(oldBot);
// }
// running = false;
// return true;
// }
//
// private static void shutdownCleanup(Bot bot) {
// clearCaches();
// // TODO unload libs?
// }
//
// /**
// * Starts the bot
// *
// * @return true if bot started successfully, false if bot was already running
// * @throws StartupException if failed to create bot properly
// */
// public static synchronized boolean startup() throws StartupException {
// if (running) {
// return false;
// }
//
// loadConfigs();
//
// if (firstStart) {
// firstStart = false;
// LibsLoader.load();
// } else {
// CommandResponseParser.reRegisterTerms();
// }
//
// init();
// try {
// createBot();
// running = true;
// } catch (BotInitException e) {
// throw new StartupException("Failed to start bot", e);
// }
// return true;
// }
//
// private static void clearCaches() {
// CommandScriptProcessor.clearScriptCache();
// FilterProcessor.clearScriptCache();
// }
//
// private static void createBot() throws BotInitException {
// // Connect to service
// Service service = Configs.getGeneralConfig().getExactlyAsOptional(GeneralConfig::getService)
// .orElseThrow(() -> new BotInitException("Failed to get service"));
// switch (service) {
// case TWITCH:
// bot = new TwitchBot();
// break;
// case BEAM:
// bot = new BeamBot();
// break;
// default:
// throw new BotInitException("Unknown service: " + service);
// }
// ThreadUtil.newSingleThreadExecutor("Bot").execute(() -> {
// try {
// App.logger.info("Bot Started");
// bot.startBot();
// App.logger.info("Bot Stopped");
// } catch (BotInitException e) {
// App.logger.catching(e);
// }
// handlePossibleFailedStartup();
// });
// }
//
// private static synchronized void handlePossibleFailedStartup() {
// if (!bot.isConnected()) {
// shutdown(true);
// }
// }
//
// private static void init() {
// loadPreloads(LoadStrategy.OVERWRITE);
// TermLoader.loadTerms();
// // TODO load filters (scripts)
// }
//
// public static void loadPreloads(LoadStrategy strategy) {
// // TODO stream over Base when filters are ready
// PreloadLoader.loadDirectory(Base.CMD, Chan.ALL, null, strategy);
// PreloadLoader.loadDirectory(Base.ALIAS, Chan.ALL, null, strategy);
// PreloadLoader.loadDirectory(Base.CMD, Chan.BOT, null, strategy);
// PreloadLoader.loadDirectory(Base.ALIAS, Chan.BOT, null, strategy);
//
// PreloadLoader.loadDirectoryForEachChannel(Base.CMD, strategy);
// PreloadLoader.loadDirectoryForEachChannel(Base.ALIAS, strategy);
// }
//
// private static void loadConfigs() {
// Configs.getGeneralConfig().updateAndAwait();
// Configs.reloadAccount();
// }
//
// public static class Graphics {
// private static boolean withGui = true;
//
// public static void useGui(boolean useGui) {
// withGui = useGui;
// }
//
// public static boolean present() {
// return withGui && !GraphicsEnvironment.isHeadless();
// }
// }
//
// public static class StartupException extends Exception {
// private StartupException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// }
|
import com.github.otbproject.otbproject.bot.Control;
import java.util.EnumSet;
import java.util.Optional;
import java.util.Set;
|
package com.github.otbproject.otbproject.channel;
@Deprecated
public class Channels {
private Channels() {}
public static boolean in(String channelName) {
|
// Path: src/main/java/com/github/otbproject/otbproject/bot/Control.java
// public class Control {
// private static volatile boolean firstStart = true;
// private static volatile boolean running = false;
// private static volatile Bot bot = NullBot.INSTANCE;
//
// private Control() {}
//
// public static Bot bot() {
// return bot;
// }
//
// /**
// * Sets the bot to the given value. Fails if bot is running.
// *
// * @param bot A {@link Bot} to set as the bot
// * @return {@code true} if successfully set new value for bot
// */
// public static synchronized boolean setBot(Bot bot) {
// if (running) {
// return false;
// }
// Control.bot = bot;
// return true;
// }
//
// /**
// * Restarts the bot. Works whether or not bot is currently running.
// *
// * @return {@code true} if bot started successfully, {@code false} if it failed to start
// */
// public static synchronized boolean restart() {
// shutdown(true);
// try {
// return startup();
// } catch (StartupException e) {
// App.logger.catching(e);
// return false;
// }
// }
//
// /**
// * Does what it says on the tin
// */
// public static void shutdownAndExit() {
// shutdown(false);
// App.logger.info("Process stopped");
// System.exit(0);
// }
//
// /**
// * Stops the bot and cleans up anything which needs to be cleaned up
// * before the bot is started again
// *
// * @param cleanup whether or not to cleanup various data with the
// * expectation that the bot will be started again
// */
// public static synchronized boolean shutdown(boolean cleanup) {
// if (!running) {
// return false;
// }
//
// App.logger.info("Shutting down bot");
// Bot oldBot = bot;
// bot = NullBot.INSTANCE; // Quickly make calls to getBot() return NullBot
// oldBot.shutdown();
// if (cleanup) {
// shutdownCleanup(oldBot);
// }
// running = false;
// return true;
// }
//
// private static void shutdownCleanup(Bot bot) {
// clearCaches();
// // TODO unload libs?
// }
//
// /**
// * Starts the bot
// *
// * @return true if bot started successfully, false if bot was already running
// * @throws StartupException if failed to create bot properly
// */
// public static synchronized boolean startup() throws StartupException {
// if (running) {
// return false;
// }
//
// loadConfigs();
//
// if (firstStart) {
// firstStart = false;
// LibsLoader.load();
// } else {
// CommandResponseParser.reRegisterTerms();
// }
//
// init();
// try {
// createBot();
// running = true;
// } catch (BotInitException e) {
// throw new StartupException("Failed to start bot", e);
// }
// return true;
// }
//
// private static void clearCaches() {
// CommandScriptProcessor.clearScriptCache();
// FilterProcessor.clearScriptCache();
// }
//
// private static void createBot() throws BotInitException {
// // Connect to service
// Service service = Configs.getGeneralConfig().getExactlyAsOptional(GeneralConfig::getService)
// .orElseThrow(() -> new BotInitException("Failed to get service"));
// switch (service) {
// case TWITCH:
// bot = new TwitchBot();
// break;
// case BEAM:
// bot = new BeamBot();
// break;
// default:
// throw new BotInitException("Unknown service: " + service);
// }
// ThreadUtil.newSingleThreadExecutor("Bot").execute(() -> {
// try {
// App.logger.info("Bot Started");
// bot.startBot();
// App.logger.info("Bot Stopped");
// } catch (BotInitException e) {
// App.logger.catching(e);
// }
// handlePossibleFailedStartup();
// });
// }
//
// private static synchronized void handlePossibleFailedStartup() {
// if (!bot.isConnected()) {
// shutdown(true);
// }
// }
//
// private static void init() {
// loadPreloads(LoadStrategy.OVERWRITE);
// TermLoader.loadTerms();
// // TODO load filters (scripts)
// }
//
// public static void loadPreloads(LoadStrategy strategy) {
// // TODO stream over Base when filters are ready
// PreloadLoader.loadDirectory(Base.CMD, Chan.ALL, null, strategy);
// PreloadLoader.loadDirectory(Base.ALIAS, Chan.ALL, null, strategy);
// PreloadLoader.loadDirectory(Base.CMD, Chan.BOT, null, strategy);
// PreloadLoader.loadDirectory(Base.ALIAS, Chan.BOT, null, strategy);
//
// PreloadLoader.loadDirectoryForEachChannel(Base.CMD, strategy);
// PreloadLoader.loadDirectoryForEachChannel(Base.ALIAS, strategy);
// }
//
// private static void loadConfigs() {
// Configs.getGeneralConfig().updateAndAwait();
// Configs.reloadAccount();
// }
//
// public static class Graphics {
// private static boolean withGui = true;
//
// public static void useGui(boolean useGui) {
// withGui = useGui;
// }
//
// public static boolean present() {
// return withGui && !GraphicsEnvironment.isHeadless();
// }
// }
//
// public static class StartupException extends Exception {
// private StartupException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/channel/Channels.java
import com.github.otbproject.otbproject.bot.Control;
import java.util.EnumSet;
import java.util.Optional;
import java.util.Set;
package com.github.otbproject.otbproject.channel;
@Deprecated
public class Channels {
private Channels() {}
public static boolean in(String channelName) {
|
return Control.bot().channelManager().in(channelName);
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/filter/Filters.java
|
// Path: src/main/java/com/github/otbproject/otbproject/util/CustomCollectors.java
// public final class CustomCollectors {
// private CustomCollectors() {}
//
// public static <T> Collector<T, ?, ConcurrentHashMap.KeySetView<T, Boolean>> toConcurrentSet() {
// return Collector.of(ConcurrentHashMap::newKeySet, ConcurrentHashMap.KeySetView::add, (c1, c2) -> {
// c1.addAll(c2);
// return c1;
// });
// }
// }
|
import com.github.otbproject.otbproject.database.DatabaseWrapper;
import com.github.otbproject.otbproject.util.CustomCollectors;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
|
package com.github.otbproject.otbproject.filter;
public class Filters {
private Filters() {}
public static Optional<BasicFilter> get(DatabaseWrapper db, String data, FilterType type) {
List<Map.Entry<String, Object>> list = new ArrayList<>();
list.add(new AbstractMap.SimpleImmutableEntry<>(FilterFields.DATA, data));
list.add(new AbstractMap.SimpleImmutableEntry<>(FilterFields.TYPE, type.name()));
return db.getRecord(FilterFields.TABLE_NAME, list, Filters::getFilterFromResultSet);
}
public static List<BasicFilter> getBasicFilters(DatabaseWrapper db) {
Optional<List<BasicFilter>> optional = db.tableDump(FilterFields.TABLE_NAME,
rs -> {
List<BasicFilter> filters = new ArrayList<>();
while (rs.next()) {
filters.add(getFilterFromResultSet(rs));
}
return filters;
});
return optional.orElse(Collections.emptyList());
}
public static ConcurrentHashMap.KeySetView<Filter, Boolean> getAllFilters(DatabaseWrapper db) {
|
// Path: src/main/java/com/github/otbproject/otbproject/util/CustomCollectors.java
// public final class CustomCollectors {
// private CustomCollectors() {}
//
// public static <T> Collector<T, ?, ConcurrentHashMap.KeySetView<T, Boolean>> toConcurrentSet() {
// return Collector.of(ConcurrentHashMap::newKeySet, ConcurrentHashMap.KeySetView::add, (c1, c2) -> {
// c1.addAll(c2);
// return c1;
// });
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/filter/Filters.java
import com.github.otbproject.otbproject.database.DatabaseWrapper;
import com.github.otbproject.otbproject.util.CustomCollectors;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
package com.github.otbproject.otbproject.filter;
public class Filters {
private Filters() {}
public static Optional<BasicFilter> get(DatabaseWrapper db, String data, FilterType type) {
List<Map.Entry<String, Object>> list = new ArrayList<>();
list.add(new AbstractMap.SimpleImmutableEntry<>(FilterFields.DATA, data));
list.add(new AbstractMap.SimpleImmutableEntry<>(FilterFields.TYPE, type.name()));
return db.getRecord(FilterFields.TABLE_NAME, list, Filters::getFilterFromResultSet);
}
public static List<BasicFilter> getBasicFilters(DatabaseWrapper db) {
Optional<List<BasicFilter>> optional = db.tableDump(FilterFields.TABLE_NAME,
rs -> {
List<BasicFilter> filters = new ArrayList<>();
while (rs.next()) {
filters.add(getFilterFromResultSet(rs));
}
return filters;
});
return optional.orElse(Collections.emptyList());
}
public static ConcurrentHashMap.KeySetView<Filter, Boolean> getAllFilters(DatabaseWrapper db) {
|
return getBasicFilters(db).stream().map(Filter::fromBasicFilter).collect(CustomCollectors.toConcurrentSet());
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/filter/FilterGroups.java
|
// Path: src/main/java/com/github/otbproject/otbproject/user/UserLevel.java
// public enum UserLevel {
// IGNORED(-10), DEFAULT(0), SUBSCRIBER(5), REGULAR(10), MODERATOR(20), SUPER_MODERATOR(30), BROADCASTER(40), INTERNAL(50), TOO_HIGH(200);
//
// private final int value;
//
// UserLevel(int userLevel) {
// this.value = userLevel;
// }
//
// public int getValue() {
// return value;
// }
// }
|
import com.github.otbproject.otbproject.database.DatabaseWrapper;
import com.github.otbproject.otbproject.user.UserLevel;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
|
package com.github.otbproject.otbproject.filter;
public class FilterGroups {
private FilterGroups() {}
public static Optional<FilterGroup> get(DatabaseWrapper db, String groupName) {
return db.getRecord(FilterGroupFields.TABLE_NAME, groupName,
FilterGroupFields.NAME, FilterGroups::getFilterGroupFromResultSet);
}
public static List<FilterGroup> getFilterGroups(DatabaseWrapper db) {
Optional<List<FilterGroup>> optional = db.tableDump(FilterGroupFields.TABLE_NAME,
rs -> {
List<FilterGroup> filterGroups = new ArrayList<>();
while (rs.next()) {
filterGroups.add(getFilterGroupFromResultSet(rs));
}
return filterGroups;
});
return optional.orElse(Collections.emptyList());
}
// The Map is implemented as a HashMap, but it returns a generic Map
public static ConcurrentMap<String, FilterGroup> getFilterGroupsMap(DatabaseWrapper db) {
return getFilterGroups(db).stream().collect(Collectors.toConcurrentMap(FilterGroup::getName, filterGroup -> filterGroup));
}
private static FilterGroup getFilterGroupFromResultSet(ResultSet rs) throws SQLException {
FilterGroup group = new FilterGroup();
group.setName(rs.getString(FilterGroupFields.NAME));
|
// Path: src/main/java/com/github/otbproject/otbproject/user/UserLevel.java
// public enum UserLevel {
// IGNORED(-10), DEFAULT(0), SUBSCRIBER(5), REGULAR(10), MODERATOR(20), SUPER_MODERATOR(30), BROADCASTER(40), INTERNAL(50), TOO_HIGH(200);
//
// private final int value;
//
// UserLevel(int userLevel) {
// this.value = userLevel;
// }
//
// public int getValue() {
// return value;
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/filter/FilterGroups.java
import com.github.otbproject.otbproject.database.DatabaseWrapper;
import com.github.otbproject.otbproject.user.UserLevel;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
package com.github.otbproject.otbproject.filter;
public class FilterGroups {
private FilterGroups() {}
public static Optional<FilterGroup> get(DatabaseWrapper db, String groupName) {
return db.getRecord(FilterGroupFields.TABLE_NAME, groupName,
FilterGroupFields.NAME, FilterGroups::getFilterGroupFromResultSet);
}
public static List<FilterGroup> getFilterGroups(DatabaseWrapper db) {
Optional<List<FilterGroup>> optional = db.tableDump(FilterGroupFields.TABLE_NAME,
rs -> {
List<FilterGroup> filterGroups = new ArrayList<>();
while (rs.next()) {
filterGroups.add(getFilterGroupFromResultSet(rs));
}
return filterGroups;
});
return optional.orElse(Collections.emptyList());
}
// The Map is implemented as a HashMap, but it returns a generic Map
public static ConcurrentMap<String, FilterGroup> getFilterGroupsMap(DatabaseWrapper db) {
return getFilterGroups(db).stream().collect(Collectors.toConcurrentMap(FilterGroup::getName, filterGroup -> filterGroup));
}
private static FilterGroup getFilterGroupFromResultSet(ResultSet rs) throws SQLException {
FilterGroup group = new FilterGroup();
group.setName(rs.getString(FilterGroupFields.NAME));
|
group.setUserLevel(UserLevel.valueOf(rs.getString(FilterGroupFields.USER_LEVEL)));
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/script/ScriptProcessorUtil.java
|
// Path: src/main/java/com/github/otbproject/otbproject/fs/FSUtil.java
// public class FSUtil {
// public static final String ERROR_MSG = "Failed to create directory: ";
// private static final String BASE_DIR_NAME = ".otbproject";
// public static final String BASE_DIR_DEFAULT = System.getProperty("user.home") + File.separator + BASE_DIR_NAME;
// private static final String ASSETS_DIR_NAME = "assets";
// private static final String ALIASES_DIR_NAME = "aliases";
// private static final String COMMANDS_DIR_NAME = "commands";
// private static final String CONFIG_DIR_NAME = "config";
// private static final String DATA_DIR_NAME = "data";
// private static final String FILTERS_DIR_NAME = "filters";
// private static final String FILTER_GROUPS_DIR_NAME = "filter-groups";
// private static final String LOGS_DIR_NAME = "logs";
// private static final String SCRIPT_DIR_NAME = "scripts";
// private static final String LIBS_DIR_NAME = "libs";
// private static final String TERMS_DIR_NAME = "terms";
// private static final String WEB_DIR_NAME = "web";
//
// public static final String GUI_HISTORY_FILE = "gui-command-history.json";
//
// private static String baseDir = BASE_DIR_DEFAULT;
//
// private FSUtil() {}
//
// public static String getBaseDir() {
// return baseDir;
// }
//
// // Assumes path does not have a trailing slash
// public static void setBaseDirPath(String path) {
// baseDir = path + File.separator + BASE_DIR_NAME;
// }
//
// public static String assetsDir() {
// return baseDir + File.separator + ASSETS_DIR_NAME;
// }
//
// public static String aliasesDir() {
// return baseDir + File.separator + ALIASES_DIR_NAME;
// }
//
// public static String commandsDir() {
// return baseDir + File.separator + COMMANDS_DIR_NAME;
// }
//
// public static String configDir() {
// return baseDir + File.separator + CONFIG_DIR_NAME;
// }
//
// public static String dataDir() {
// return baseDir + File.separator + DATA_DIR_NAME;
// }
//
// public static String channelDataDir(String channel) {
// return dataDir() + File.separator + DirNames.CHANNELS + File.separator + channel;
// }
//
// private static String filtersBaseDir() {
// return baseDir + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String filtersDir() {
// return filtersBaseDir() + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String filterGroupsDir() {
// return filtersBaseDir() + File.separator + FILTER_GROUPS_DIR_NAME;
// }
//
// public static String logsDir() {
// return baseDir + File.separator + LOGS_DIR_NAME;
// }
//
// public static String scriptDir() {
// return baseDir + File.separator + SCRIPT_DIR_NAME;
// }
//
// public static String commandScriptDir() {
// return scriptDir() + File.separator + COMMANDS_DIR_NAME;
// }
//
// public static String scriptLibsDir() {
// return scriptDir() + File.separator + LIBS_DIR_NAME;
// }
//
// public static String termScriptDir() {
// return scriptDir() + File.separator + TERMS_DIR_NAME;
// }
//
// public static String filterScriptDir() {
// return scriptDir() + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String webDir() {
// return baseDir + File.separator + WEB_DIR_NAME;
// }
//
// public static Stream<File> streamDirectory(File directory) {
// return streamDirectory(directory, "Error listing files for directory: " + directory.getPath());
// }
//
// public static Stream<File> streamDirectory(File directory, String errMsg) {
// File[] files = directory.listFiles();
// if (files == null) {
// App.logger.error(errMsg);
// return Stream.empty();
// }
// return Stream.of(files);
// }
//
// public static class DirNames {
// public static final String ALL_CHANNELS = "all-channels";
// public static final String BOT_CHANNEL = "bot-channel";
// public static final String CHANNELS = "channels";
//
// public static final String LOADED = "loaded";
// public static final String TO_LOAD = "to-load";
// public static final String FAILED = "failed";
// }
//
// public static class DatabaseNames {
// public static final String MAIN = "main.db";
// public static final String QUOTES = "quotes.db";
// }
//
// public static class ConfigFileNames {
// public static final String ACCOUNT_TWITCH = "account-twitch.json";
// public static final String ACCOUNT_BEAM = "account-beam.json";
// public static final String GENERAL_CONFIG = "general-config.json";
// public static final String BOT_CONFIG = "bot-config.json";
// public static final String CHANNEL_CONFIG = "config.json";
// public static final String WEB_CONFIG = "web-config.json";
// }
//
// public static class Assets {
// public static final String LOGO = "logo.png";
// }
// }
|
import com.github.otbproject.otbproject.fs.FSUtil;
import java.io.File;
|
package com.github.otbproject.otbproject.script;
public class ScriptProcessorUtil {
private ScriptProcessorUtil() {}
public static void cacheFromDirectory(ScriptProcessor processor, String directory) {
|
// Path: src/main/java/com/github/otbproject/otbproject/fs/FSUtil.java
// public class FSUtil {
// public static final String ERROR_MSG = "Failed to create directory: ";
// private static final String BASE_DIR_NAME = ".otbproject";
// public static final String BASE_DIR_DEFAULT = System.getProperty("user.home") + File.separator + BASE_DIR_NAME;
// private static final String ASSETS_DIR_NAME = "assets";
// private static final String ALIASES_DIR_NAME = "aliases";
// private static final String COMMANDS_DIR_NAME = "commands";
// private static final String CONFIG_DIR_NAME = "config";
// private static final String DATA_DIR_NAME = "data";
// private static final String FILTERS_DIR_NAME = "filters";
// private static final String FILTER_GROUPS_DIR_NAME = "filter-groups";
// private static final String LOGS_DIR_NAME = "logs";
// private static final String SCRIPT_DIR_NAME = "scripts";
// private static final String LIBS_DIR_NAME = "libs";
// private static final String TERMS_DIR_NAME = "terms";
// private static final String WEB_DIR_NAME = "web";
//
// public static final String GUI_HISTORY_FILE = "gui-command-history.json";
//
// private static String baseDir = BASE_DIR_DEFAULT;
//
// private FSUtil() {}
//
// public static String getBaseDir() {
// return baseDir;
// }
//
// // Assumes path does not have a trailing slash
// public static void setBaseDirPath(String path) {
// baseDir = path + File.separator + BASE_DIR_NAME;
// }
//
// public static String assetsDir() {
// return baseDir + File.separator + ASSETS_DIR_NAME;
// }
//
// public static String aliasesDir() {
// return baseDir + File.separator + ALIASES_DIR_NAME;
// }
//
// public static String commandsDir() {
// return baseDir + File.separator + COMMANDS_DIR_NAME;
// }
//
// public static String configDir() {
// return baseDir + File.separator + CONFIG_DIR_NAME;
// }
//
// public static String dataDir() {
// return baseDir + File.separator + DATA_DIR_NAME;
// }
//
// public static String channelDataDir(String channel) {
// return dataDir() + File.separator + DirNames.CHANNELS + File.separator + channel;
// }
//
// private static String filtersBaseDir() {
// return baseDir + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String filtersDir() {
// return filtersBaseDir() + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String filterGroupsDir() {
// return filtersBaseDir() + File.separator + FILTER_GROUPS_DIR_NAME;
// }
//
// public static String logsDir() {
// return baseDir + File.separator + LOGS_DIR_NAME;
// }
//
// public static String scriptDir() {
// return baseDir + File.separator + SCRIPT_DIR_NAME;
// }
//
// public static String commandScriptDir() {
// return scriptDir() + File.separator + COMMANDS_DIR_NAME;
// }
//
// public static String scriptLibsDir() {
// return scriptDir() + File.separator + LIBS_DIR_NAME;
// }
//
// public static String termScriptDir() {
// return scriptDir() + File.separator + TERMS_DIR_NAME;
// }
//
// public static String filterScriptDir() {
// return scriptDir() + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String webDir() {
// return baseDir + File.separator + WEB_DIR_NAME;
// }
//
// public static Stream<File> streamDirectory(File directory) {
// return streamDirectory(directory, "Error listing files for directory: " + directory.getPath());
// }
//
// public static Stream<File> streamDirectory(File directory, String errMsg) {
// File[] files = directory.listFiles();
// if (files == null) {
// App.logger.error(errMsg);
// return Stream.empty();
// }
// return Stream.of(files);
// }
//
// public static class DirNames {
// public static final String ALL_CHANNELS = "all-channels";
// public static final String BOT_CHANNEL = "bot-channel";
// public static final String CHANNELS = "channels";
//
// public static final String LOADED = "loaded";
// public static final String TO_LOAD = "to-load";
// public static final String FAILED = "failed";
// }
//
// public static class DatabaseNames {
// public static final String MAIN = "main.db";
// public static final String QUOTES = "quotes.db";
// }
//
// public static class ConfigFileNames {
// public static final String ACCOUNT_TWITCH = "account-twitch.json";
// public static final String ACCOUNT_BEAM = "account-beam.json";
// public static final String GENERAL_CONFIG = "general-config.json";
// public static final String BOT_CONFIG = "bot-config.json";
// public static final String CHANNEL_CONFIG = "config.json";
// public static final String WEB_CONFIG = "web-config.json";
// }
//
// public static class Assets {
// public static final String LOGO = "logo.png";
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/script/ScriptProcessorUtil.java
import com.github.otbproject.otbproject.fs.FSUtil;
import java.io.File;
package com.github.otbproject.otbproject.script;
public class ScriptProcessorUtil {
private ScriptProcessorUtil() {}
public static void cacheFromDirectory(ScriptProcessor processor, String directory) {
|
FSUtil.streamDirectory(new File(directory))
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/filter/FilterFields.java
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
|
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
|
package com.github.otbproject.otbproject.filter;
public class FilterFields {
public static final String DATA = "data";
public static final String TYPE = "type";
public static final String GROUP = "filterGroup";
public static final String ENABLED = "enabled";
public static final String TABLE_NAME = "tblFilters";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(DATA);
PRIMARY_KEYS.add(TYPE);
}
private FilterFields() {}
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/filter/FilterFields.java
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
package com.github.otbproject.otbproject.filter;
public class FilterFields {
public static final String DATA = "data";
public static final String TYPE = "type";
public static final String GROUP = "filterGroup";
public static final String ENABLED = "enabled";
public static final String TABLE_NAME = "tblFilters";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(DATA);
PRIMARY_KEYS.add(TYPE);
}
private FilterFields() {}
|
public static TableFields getTableFields() {
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/filter/FilterFields.java
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
|
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
|
package com.github.otbproject.otbproject.filter;
public class FilterFields {
public static final String DATA = "data";
public static final String TYPE = "type";
public static final String GROUP = "filterGroup";
public static final String ENABLED = "enabled";
public static final String TABLE_NAME = "tblFilters";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(DATA);
PRIMARY_KEYS.add(TYPE);
}
private FilterFields() {}
public static TableFields getTableFields() {
HashMap<String, String> map = new HashMap<>();
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/filter/FilterFields.java
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
package com.github.otbproject.otbproject.filter;
public class FilterFields {
public static final String DATA = "data";
public static final String TYPE = "type";
public static final String GROUP = "filterGroup";
public static final String ENABLED = "enabled";
public static final String TABLE_NAME = "tblFilters";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(DATA);
PRIMARY_KEYS.add(TYPE);
}
private FilterFields() {}
public static TableFields getTableFields() {
HashMap<String, String> map = new HashMap<>();
|
map.put(DATA, DataTypes.STRING);
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/database/Databases.java
|
// Path: src/main/java/com/github/otbproject/otbproject/fs/FSUtil.java
// public class FSUtil {
// public static final String ERROR_MSG = "Failed to create directory: ";
// private static final String BASE_DIR_NAME = ".otbproject";
// public static final String BASE_DIR_DEFAULT = System.getProperty("user.home") + File.separator + BASE_DIR_NAME;
// private static final String ASSETS_DIR_NAME = "assets";
// private static final String ALIASES_DIR_NAME = "aliases";
// private static final String COMMANDS_DIR_NAME = "commands";
// private static final String CONFIG_DIR_NAME = "config";
// private static final String DATA_DIR_NAME = "data";
// private static final String FILTERS_DIR_NAME = "filters";
// private static final String FILTER_GROUPS_DIR_NAME = "filter-groups";
// private static final String LOGS_DIR_NAME = "logs";
// private static final String SCRIPT_DIR_NAME = "scripts";
// private static final String LIBS_DIR_NAME = "libs";
// private static final String TERMS_DIR_NAME = "terms";
// private static final String WEB_DIR_NAME = "web";
//
// public static final String GUI_HISTORY_FILE = "gui-command-history.json";
//
// private static String baseDir = BASE_DIR_DEFAULT;
//
// private FSUtil() {}
//
// public static String getBaseDir() {
// return baseDir;
// }
//
// // Assumes path does not have a trailing slash
// public static void setBaseDirPath(String path) {
// baseDir = path + File.separator + BASE_DIR_NAME;
// }
//
// public static String assetsDir() {
// return baseDir + File.separator + ASSETS_DIR_NAME;
// }
//
// public static String aliasesDir() {
// return baseDir + File.separator + ALIASES_DIR_NAME;
// }
//
// public static String commandsDir() {
// return baseDir + File.separator + COMMANDS_DIR_NAME;
// }
//
// public static String configDir() {
// return baseDir + File.separator + CONFIG_DIR_NAME;
// }
//
// public static String dataDir() {
// return baseDir + File.separator + DATA_DIR_NAME;
// }
//
// public static String channelDataDir(String channel) {
// return dataDir() + File.separator + DirNames.CHANNELS + File.separator + channel;
// }
//
// private static String filtersBaseDir() {
// return baseDir + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String filtersDir() {
// return filtersBaseDir() + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String filterGroupsDir() {
// return filtersBaseDir() + File.separator + FILTER_GROUPS_DIR_NAME;
// }
//
// public static String logsDir() {
// return baseDir + File.separator + LOGS_DIR_NAME;
// }
//
// public static String scriptDir() {
// return baseDir + File.separator + SCRIPT_DIR_NAME;
// }
//
// public static String commandScriptDir() {
// return scriptDir() + File.separator + COMMANDS_DIR_NAME;
// }
//
// public static String scriptLibsDir() {
// return scriptDir() + File.separator + LIBS_DIR_NAME;
// }
//
// public static String termScriptDir() {
// return scriptDir() + File.separator + TERMS_DIR_NAME;
// }
//
// public static String filterScriptDir() {
// return scriptDir() + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String webDir() {
// return baseDir + File.separator + WEB_DIR_NAME;
// }
//
// public static Stream<File> streamDirectory(File directory) {
// return streamDirectory(directory, "Error listing files for directory: " + directory.getPath());
// }
//
// public static Stream<File> streamDirectory(File directory, String errMsg) {
// File[] files = directory.listFiles();
// if (files == null) {
// App.logger.error(errMsg);
// return Stream.empty();
// }
// return Stream.of(files);
// }
//
// public static class DirNames {
// public static final String ALL_CHANNELS = "all-channels";
// public static final String BOT_CHANNEL = "bot-channel";
// public static final String CHANNELS = "channels";
//
// public static final String LOADED = "loaded";
// public static final String TO_LOAD = "to-load";
// public static final String FAILED = "failed";
// }
//
// public static class DatabaseNames {
// public static final String MAIN = "main.db";
// public static final String QUOTES = "quotes.db";
// }
//
// public static class ConfigFileNames {
// public static final String ACCOUNT_TWITCH = "account-twitch.json";
// public static final String ACCOUNT_BEAM = "account-beam.json";
// public static final String GENERAL_CONFIG = "general-config.json";
// public static final String BOT_CONFIG = "bot-config.json";
// public static final String CHANNEL_CONFIG = "config.json";
// public static final String WEB_CONFIG = "web-config.json";
// }
//
// public static class Assets {
// public static final String LOGO = "logo.png";
// }
// }
|
import com.github.otbproject.otbproject.fs.FSUtil;
import java.io.File;
|
package com.github.otbproject.otbproject.database;
public class Databases {
private Databases() {}
public static DatabaseWrapper createChannelMainDbWrapper(String channel) {
|
// Path: src/main/java/com/github/otbproject/otbproject/fs/FSUtil.java
// public class FSUtil {
// public static final String ERROR_MSG = "Failed to create directory: ";
// private static final String BASE_DIR_NAME = ".otbproject";
// public static final String BASE_DIR_DEFAULT = System.getProperty("user.home") + File.separator + BASE_DIR_NAME;
// private static final String ASSETS_DIR_NAME = "assets";
// private static final String ALIASES_DIR_NAME = "aliases";
// private static final String COMMANDS_DIR_NAME = "commands";
// private static final String CONFIG_DIR_NAME = "config";
// private static final String DATA_DIR_NAME = "data";
// private static final String FILTERS_DIR_NAME = "filters";
// private static final String FILTER_GROUPS_DIR_NAME = "filter-groups";
// private static final String LOGS_DIR_NAME = "logs";
// private static final String SCRIPT_DIR_NAME = "scripts";
// private static final String LIBS_DIR_NAME = "libs";
// private static final String TERMS_DIR_NAME = "terms";
// private static final String WEB_DIR_NAME = "web";
//
// public static final String GUI_HISTORY_FILE = "gui-command-history.json";
//
// private static String baseDir = BASE_DIR_DEFAULT;
//
// private FSUtil() {}
//
// public static String getBaseDir() {
// return baseDir;
// }
//
// // Assumes path does not have a trailing slash
// public static void setBaseDirPath(String path) {
// baseDir = path + File.separator + BASE_DIR_NAME;
// }
//
// public static String assetsDir() {
// return baseDir + File.separator + ASSETS_DIR_NAME;
// }
//
// public static String aliasesDir() {
// return baseDir + File.separator + ALIASES_DIR_NAME;
// }
//
// public static String commandsDir() {
// return baseDir + File.separator + COMMANDS_DIR_NAME;
// }
//
// public static String configDir() {
// return baseDir + File.separator + CONFIG_DIR_NAME;
// }
//
// public static String dataDir() {
// return baseDir + File.separator + DATA_DIR_NAME;
// }
//
// public static String channelDataDir(String channel) {
// return dataDir() + File.separator + DirNames.CHANNELS + File.separator + channel;
// }
//
// private static String filtersBaseDir() {
// return baseDir + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String filtersDir() {
// return filtersBaseDir() + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String filterGroupsDir() {
// return filtersBaseDir() + File.separator + FILTER_GROUPS_DIR_NAME;
// }
//
// public static String logsDir() {
// return baseDir + File.separator + LOGS_DIR_NAME;
// }
//
// public static String scriptDir() {
// return baseDir + File.separator + SCRIPT_DIR_NAME;
// }
//
// public static String commandScriptDir() {
// return scriptDir() + File.separator + COMMANDS_DIR_NAME;
// }
//
// public static String scriptLibsDir() {
// return scriptDir() + File.separator + LIBS_DIR_NAME;
// }
//
// public static String termScriptDir() {
// return scriptDir() + File.separator + TERMS_DIR_NAME;
// }
//
// public static String filterScriptDir() {
// return scriptDir() + File.separator + FILTERS_DIR_NAME;
// }
//
// public static String webDir() {
// return baseDir + File.separator + WEB_DIR_NAME;
// }
//
// public static Stream<File> streamDirectory(File directory) {
// return streamDirectory(directory, "Error listing files for directory: " + directory.getPath());
// }
//
// public static Stream<File> streamDirectory(File directory, String errMsg) {
// File[] files = directory.listFiles();
// if (files == null) {
// App.logger.error(errMsg);
// return Stream.empty();
// }
// return Stream.of(files);
// }
//
// public static class DirNames {
// public static final String ALL_CHANNELS = "all-channels";
// public static final String BOT_CHANNEL = "bot-channel";
// public static final String CHANNELS = "channels";
//
// public static final String LOADED = "loaded";
// public static final String TO_LOAD = "to-load";
// public static final String FAILED = "failed";
// }
//
// public static class DatabaseNames {
// public static final String MAIN = "main.db";
// public static final String QUOTES = "quotes.db";
// }
//
// public static class ConfigFileNames {
// public static final String ACCOUNT_TWITCH = "account-twitch.json";
// public static final String ACCOUNT_BEAM = "account-beam.json";
// public static final String GENERAL_CONFIG = "general-config.json";
// public static final String BOT_CONFIG = "bot-config.json";
// public static final String CHANNEL_CONFIG = "config.json";
// public static final String WEB_CONFIG = "web-config.json";
// }
//
// public static class Assets {
// public static final String LOGO = "logo.png";
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/database/Databases.java
import com.github.otbproject.otbproject.fs.FSUtil;
import java.io.File;
package com.github.otbproject.otbproject.database;
public class Databases {
private Databases() {}
public static DatabaseWrapper createChannelMainDbWrapper(String channel) {
|
String path = FSUtil.dataDir() + File.separator + FSUtil.DirNames.CHANNELS + File.separator + channel + File.separator + FSUtil.DatabaseNames.MAIN;
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/command/scheduler/SchedulerFields.java
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
|
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
|
package com.github.otbproject.otbproject.command.scheduler;
public class SchedulerFields {
public static final String COMMAND = "command";
public static final String TYPE = "type";
public static final String OFFSET = "offset";
public static final String PERIOD = "period";
public static final String RESET = "reset";
public static final String TABLE_NAME = "tblSchedule";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(COMMAND);
}
private SchedulerFields() {}
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/command/scheduler/SchedulerFields.java
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
package com.github.otbproject.otbproject.command.scheduler;
public class SchedulerFields {
public static final String COMMAND = "command";
public static final String TYPE = "type";
public static final String OFFSET = "offset";
public static final String PERIOD = "period";
public static final String RESET = "reset";
public static final String TABLE_NAME = "tblSchedule";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(COMMAND);
}
private SchedulerFields() {}
|
public static TableFields getTableFields() {
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/command/scheduler/SchedulerFields.java
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
|
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
|
package com.github.otbproject.otbproject.command.scheduler;
public class SchedulerFields {
public static final String COMMAND = "command";
public static final String TYPE = "type";
public static final String OFFSET = "offset";
public static final String PERIOD = "period";
public static final String RESET = "reset";
public static final String TABLE_NAME = "tblSchedule";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(COMMAND);
}
private SchedulerFields() {}
public static TableFields getTableFields() {
HashMap<String, String> fields = new HashMap<>();
|
// Path: src/main/java/com/github/otbproject/otbproject/database/DataTypes.java
// public class DataTypes {
// public static final String STRING = "TEXT COLLATE NOCASE";
// public static final String INTEGER = "INTEGER";
//
// private DataTypes() {}
// }
//
// Path: src/main/java/com/github/otbproject/otbproject/database/TableFields.java
// public class TableFields {
// public final HashMap<String, String> map;
// public final HashSet<String> primaryKeys;
//
// public TableFields(HashMap<String, String> map, HashSet<String> primaryKeys) {
// this.map = map;
// this.primaryKeys = primaryKeys;
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/command/scheduler/SchedulerFields.java
import com.github.otbproject.otbproject.database.DataTypes;
import com.github.otbproject.otbproject.database.TableFields;
import java.util.HashMap;
import java.util.HashSet;
package com.github.otbproject.otbproject.command.scheduler;
public class SchedulerFields {
public static final String COMMAND = "command";
public static final String TYPE = "type";
public static final String OFFSET = "offset";
public static final String PERIOD = "period";
public static final String RESET = "reset";
public static final String TABLE_NAME = "tblSchedule";
static final HashSet<String> PRIMARY_KEYS = new HashSet<>();
static {
PRIMARY_KEYS.add(COMMAND);
}
private SchedulerFields() {}
public static TableFields getTableFields() {
HashMap<String, String> fields = new HashMap<>();
|
fields.put(COMMAND, DataTypes.STRING);
|
OTBProject/OTBProject
|
src/main/java/com/github/otbproject/otbproject/bot/BotUtil.java
|
// Path: src/main/java/com/github/otbproject/otbproject/user/UserLevel.java
// public enum UserLevel {
// IGNORED(-10), DEFAULT(0), SUBSCRIBER(5), REGULAR(10), MODERATOR(20), SUPER_MODERATOR(30), BROADCASTER(40), INTERNAL(50), TOO_HIGH(200);
//
// private final int value;
//
// UserLevel(int userLevel) {
// this.value = userLevel;
// }
//
// public int getValue() {
// return value;
// }
// }
|
import com.github.otbproject.otbproject.channel.ChannelNotFoundException;
import com.github.otbproject.otbproject.channel.ChannelProxy;
import com.github.otbproject.otbproject.database.DatabaseWrapper;
import com.github.otbproject.otbproject.user.UserLevel;
import com.github.otbproject.otbproject.user.UserLevels;
|
package com.github.otbproject.otbproject.bot;
public class BotUtil {
private BotUtil() {}
public static boolean isModOrHigher(String channelName, String user) throws ChannelNotFoundException {
// Check if user has user level mod or higher
ChannelProxy channel = Control.bot().channelManager().getOrThrow(channelName);
DatabaseWrapper db = channel.getMainDatabaseWrapper();
|
// Path: src/main/java/com/github/otbproject/otbproject/user/UserLevel.java
// public enum UserLevel {
// IGNORED(-10), DEFAULT(0), SUBSCRIBER(5), REGULAR(10), MODERATOR(20), SUPER_MODERATOR(30), BROADCASTER(40), INTERNAL(50), TOO_HIGH(200);
//
// private final int value;
//
// UserLevel(int userLevel) {
// this.value = userLevel;
// }
//
// public int getValue() {
// return value;
// }
// }
// Path: src/main/java/com/github/otbproject/otbproject/bot/BotUtil.java
import com.github.otbproject.otbproject.channel.ChannelNotFoundException;
import com.github.otbproject.otbproject.channel.ChannelProxy;
import com.github.otbproject.otbproject.database.DatabaseWrapper;
import com.github.otbproject.otbproject.user.UserLevel;
import com.github.otbproject.otbproject.user.UserLevels;
package com.github.otbproject.otbproject.bot;
public class BotUtil {
private BotUtil() {}
public static boolean isModOrHigher(String channelName, String user) throws ChannelNotFoundException {
// Check if user has user level mod or higher
ChannelProxy channel = Control.bot().channelManager().getOrThrow(channelName);
DatabaseWrapper db = channel.getMainDatabaseWrapper();
|
UserLevel ul = UserLevels.getUserLevel(db, channelName, user);
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/model/LeituraModel.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
|
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
|
package br.com.delogic.leitoor.model;
public class LeituraModel {
private Aluno aluno;
private Integer paginasAcessiveis;
private Integer paginaAtual;
private Integer quantidadePaginas;
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/model/LeituraModel.java
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
package br.com.delogic.leitoor.model;
public class LeituraModel {
private Aluno aluno;
private Integer paginasAcessiveis;
private Integer paginaAtual;
private Integer quantidadePaginas;
|
private Leitura leitura;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/model/LeituraModel.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
|
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
|
package br.com.delogic.leitoor.model;
public class LeituraModel {
private Aluno aluno;
private Integer paginasAcessiveis;
private Integer paginaAtual;
private Integer quantidadePaginas;
private Leitura leitura;
private String arquivoPagina;
private boolean tempoMinimoUltrapassado;
private boolean completa;
private Integer tempoDecorrido;
private Integer tempoMinimo;
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/model/LeituraModel.java
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
package br.com.delogic.leitoor.model;
public class LeituraModel {
private Aluno aluno;
private Integer paginasAcessiveis;
private Integer paginaAtual;
private Integer quantidadePaginas;
private Leitura leitura;
private String arquivoPagina;
private boolean tempoMinimoUltrapassado;
private boolean completa;
private Integer tempoDecorrido;
private Integer tempoMinimo;
|
private Atividade atividade;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/model/LeituraModel.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
|
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
|
package br.com.delogic.leitoor.model;
public class LeituraModel {
private Aluno aluno;
private Integer paginasAcessiveis;
private Integer paginaAtual;
private Integer quantidadePaginas;
private Leitura leitura;
private String arquivoPagina;
private boolean tempoMinimoUltrapassado;
private boolean completa;
private Integer tempoDecorrido;
private Integer tempoMinimo;
private Atividade atividade;
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/model/LeituraModel.java
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
package br.com.delogic.leitoor.model;
public class LeituraModel {
private Aluno aluno;
private Integer paginasAcessiveis;
private Integer paginaAtual;
private Integer quantidadePaginas;
private Leitura leitura;
private String arquivoPagina;
private boolean tempoMinimoUltrapassado;
private boolean completa;
private Integer tempoDecorrido;
private Integer tempoMinimo;
private Atividade atividade;
|
private Tarefa tarefa;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/model/QuestionarioModel.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Questao.java
// @Entity
// @Inheritance(strategy = InheritanceType.JOINED)
// @DiscriminatorColumn(name = "TIPO", length = 50)
// public abstract class Questao extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_questao")
// @SequenceGenerator(name = "seq_questao", sequenceName = "seq_questao", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 1000)
// private String descricao;
//
// private Integer peso;
//
// @ElementCollection
// @CollectionTable(name = "QUESTAOHABILIDADE")
// @Column(name = "habilidade", length = 50)
// private List<String> habilidades;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public List<String> getHabilidades() {
// return habilidades;
// }
//
// public void setHabilidades(List<String> habilidades) {
// this.habilidades = habilidades;
// }
//
// public Integer getPeso() {
// return peso;
// }
//
// public void setPeso(Integer peso) {
// this.peso = peso;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Resposta.java
// @Entity
// @Inheritance(strategy = InheritanceType.JOINED)
// @DiscriminatorColumn(name = "TIPO", length = 50)
// public abstract class Resposta extends Identity<Integer> {
//
// public abstract String getAlternativaSelecionada();
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_resposta")
// @SequenceGenerator(name = "seq_resposta", sequenceName = "seq_resposta", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// @ManyToOne
// private Questao questao;
//
// @Enumerated(EnumType.STRING)
// @Column(length = 50)
// private Avaliacao avaliacao;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Questao getQuestao() {
// return questao;
// }
//
// public void setQuestao(Questao questao) {
// this.questao = questao;
// }
//
// public Avaliacao getAvaliacao() {
// return avaliacao;
// }
//
// public void setAvaliacao(Avaliacao avaliacao) {
// this.avaliacao = avaliacao;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// }
|
import java.util.List;
import br.com.delogic.leitoor.entidade.Questao;
import br.com.delogic.leitoor.entidade.Resposta;
|
package br.com.delogic.leitoor.model;
public class QuestionarioModel {
List<Questao> questoes;
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Questao.java
// @Entity
// @Inheritance(strategy = InheritanceType.JOINED)
// @DiscriminatorColumn(name = "TIPO", length = 50)
// public abstract class Questao extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_questao")
// @SequenceGenerator(name = "seq_questao", sequenceName = "seq_questao", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 1000)
// private String descricao;
//
// private Integer peso;
//
// @ElementCollection
// @CollectionTable(name = "QUESTAOHABILIDADE")
// @Column(name = "habilidade", length = 50)
// private List<String> habilidades;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public List<String> getHabilidades() {
// return habilidades;
// }
//
// public void setHabilidades(List<String> habilidades) {
// this.habilidades = habilidades;
// }
//
// public Integer getPeso() {
// return peso;
// }
//
// public void setPeso(Integer peso) {
// this.peso = peso;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Resposta.java
// @Entity
// @Inheritance(strategy = InheritanceType.JOINED)
// @DiscriminatorColumn(name = "TIPO", length = 50)
// public abstract class Resposta extends Identity<Integer> {
//
// public abstract String getAlternativaSelecionada();
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_resposta")
// @SequenceGenerator(name = "seq_resposta", sequenceName = "seq_resposta", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// @ManyToOne
// private Questao questao;
//
// @Enumerated(EnumType.STRING)
// @Column(length = 50)
// private Avaliacao avaliacao;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Questao getQuestao() {
// return questao;
// }
//
// public void setQuestao(Questao questao) {
// this.questao = questao;
// }
//
// public Avaliacao getAvaliacao() {
// return avaliacao;
// }
//
// public void setAvaliacao(Avaliacao avaliacao) {
// this.avaliacao = avaliacao;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/model/QuestionarioModel.java
import java.util.List;
import br.com.delogic.leitoor.entidade.Questao;
import br.com.delogic.leitoor.entidade.Resposta;
package br.com.delogic.leitoor.model;
public class QuestionarioModel {
List<Questao> questoes;
|
List<Resposta> respostas;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/entidade/Usuario.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/enums/RedeSocial.java
// public enum RedeSocial {
//
// FACEBOOK, GOOGLE;
//
// }
|
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import br.com.delogic.jfunk.data.Identity;
import br.com.delogic.leitoor.entidade.enums.RedeSocial;
|
package br.com.delogic.leitoor.entidade;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "PERFIL", length = 50)
public abstract class Usuario extends Identity<Integer> {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_usuario")
@SequenceGenerator(name = "seq_usuario", sequenceName = "seq_usuario", allocationSize = 1, initialValue = 1)
private Integer id;
@Column(unique = true, length = 50)
private String idFacebook;
@Column(unique = true, length = 50)
private String idGoogle;
@Column(unique = true, length = 100)
private String email;
@Column(length = 100)
private String nome;
private Boolean ativo;
@Column(unique = true, length = 50)
private String convite;
@Enumerated(EnumType.STRING)
@Column(length = 50)
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/enums/RedeSocial.java
// public enum RedeSocial {
//
// FACEBOOK, GOOGLE;
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Usuario.java
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import br.com.delogic.jfunk.data.Identity;
import br.com.delogic.leitoor.entidade.enums.RedeSocial;
package br.com.delogic.leitoor.entidade;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "PERFIL", length = 50)
public abstract class Usuario extends Identity<Integer> {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_usuario")
@SequenceGenerator(name = "seq_usuario", sequenceName = "seq_usuario", allocationSize = 1, initialValue = 1)
private Integer id;
@Column(unique = true, length = 50)
private String idFacebook;
@Column(unique = true, length = 50)
private String idGoogle;
@Column(unique = true, length = 100)
private String email;
@Column(length = 100)
private String nome;
private Boolean ativo;
@Column(unique = true, length = 50)
private String convite;
@Enumerated(EnumType.STRING)
@Column(length = 50)
|
private RedeSocial redeSocial;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/repository/TurmaRepository.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Professor.java
// @Entity
// @DiscriminatorValue("PROFESSOR")
// public class Professor extends Aluno {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Turma.java
// @Entity
// public class Turma extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_turma")
// @SequenceGenerator(name = "seq_turma", sequenceName = "seq_turma", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String nome;
//
// @ManyToMany
// @CollectionTable
// private Set<Aluno> alunos;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getNome() {
// return nome;
// }
//
// public void setNome(String nome) {
// this.nome = nome;
// }
//
// public Set<Aluno> getAlunos() {
// return alunos;
// }
//
// public void setAlunos(Set<Aluno> alunos) {
// this.alunos = alunos;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/repository/config/EntityRepository.java
// @NoRepositoryBean
// public interface EntityRepository<T extends Identifiable<Integer>, ID extends Serializable> extends Repository<T, ID> {
//
// /**
// * Finds and returns an entity given his id
// *
// * @param id
// * to look for
// * @return entity found or null
// */
// T findById(ID id);
//
// /**
// * Creates an entity
// *
// * @param entity
// * to be created
// * @return the entity created with its id filled in
// */
// T create(T entity);
//
// /**
// * Creates entities in bulk execution
// *
// * @param entities
// * @return
// */
// <C extends Collection<? extends T>> C create(C entities);
//
// /**
// * Updates the entity values if there are any updates to be performed
// *
// * @param entity
// * @return
// */
// T update(T entity);
//
// /**
// * Updates the entities in bulk execution
// *
// * @param entities
// * @return
// */
// <C extends Collection<? extends T>> C update(C entities);
//
// /**
// * Deletes the entity values if there are any updates to be performed
// *
// * @param entity
// * @return
// */
// T delete(T entity);
//
// /**
// * Deletes the entities in bulk execution
// *
// * @param entities
// * @return
// */
// Collection<? extends T> delete(Collection<? extends T> entities);
//
// }
|
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Professor;
import br.com.delogic.leitoor.entidade.Turma;
import br.com.delogic.leitoor.repository.config.EntityRepository;
|
package br.com.delogic.leitoor.repository;
public interface TurmaRepository extends EntityRepository<Turma, Integer> {
List<Turma> findByAlunosIn(Aluno convidado);
@Query(value="select distinct t.turma from Tarefa t where t.professor = ?1 ")
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Professor.java
// @Entity
// @DiscriminatorValue("PROFESSOR")
// public class Professor extends Aluno {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Turma.java
// @Entity
// public class Turma extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_turma")
// @SequenceGenerator(name = "seq_turma", sequenceName = "seq_turma", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String nome;
//
// @ManyToMany
// @CollectionTable
// private Set<Aluno> alunos;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getNome() {
// return nome;
// }
//
// public void setNome(String nome) {
// this.nome = nome;
// }
//
// public Set<Aluno> getAlunos() {
// return alunos;
// }
//
// public void setAlunos(Set<Aluno> alunos) {
// this.alunos = alunos;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/repository/config/EntityRepository.java
// @NoRepositoryBean
// public interface EntityRepository<T extends Identifiable<Integer>, ID extends Serializable> extends Repository<T, ID> {
//
// /**
// * Finds and returns an entity given his id
// *
// * @param id
// * to look for
// * @return entity found or null
// */
// T findById(ID id);
//
// /**
// * Creates an entity
// *
// * @param entity
// * to be created
// * @return the entity created with its id filled in
// */
// T create(T entity);
//
// /**
// * Creates entities in bulk execution
// *
// * @param entities
// * @return
// */
// <C extends Collection<? extends T>> C create(C entities);
//
// /**
// * Updates the entity values if there are any updates to be performed
// *
// * @param entity
// * @return
// */
// T update(T entity);
//
// /**
// * Updates the entities in bulk execution
// *
// * @param entities
// * @return
// */
// <C extends Collection<? extends T>> C update(C entities);
//
// /**
// * Deletes the entity values if there are any updates to be performed
// *
// * @param entity
// * @return
// */
// T delete(T entity);
//
// /**
// * Deletes the entities in bulk execution
// *
// * @param entities
// * @return
// */
// Collection<? extends T> delete(Collection<? extends T> entities);
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/repository/TurmaRepository.java
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Professor;
import br.com.delogic.leitoor.entidade.Turma;
import br.com.delogic.leitoor.repository.config.EntityRepository;
package br.com.delogic.leitoor.repository;
public interface TurmaRepository extends EntityRepository<Turma, Integer> {
List<Turma> findByAlunosIn(Aluno convidado);
@Query(value="select distinct t.turma from Tarefa t where t.professor = ?1 ")
|
List<Turma> findByTurmaByProfessor(Professor p);
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/service/GoogleService.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/LeitoorException.java
// @SuppressWarnings("serial")
// public class LeitoorException extends Exception {
//
// public LeitoorException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LeitoorException(String message) {
// super(message);
// }
//
// public static LeitoorException conviteInvalidoException(String convite) {
// return new LeitoorException("Este convite não possui validade em nosso sistema:" + convite);
// }
//
// public static LeitoorException contaInvalidaException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// public static LeitoorException autenticacaoException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/RegraNegocioException.java
// @SuppressWarnings("serial")
// public class RegraNegocioException extends ViolacaoException {
//
// public RegraNegocioException(String message) {
// super(message);
// }
//
// public RegraNegocioException() {
// super(null);
// }
//
// public static RegraNegocioException of(String message) {
// return new RegraNegocioException(message);
// }
//
// public RegraNegocioException withMessage(String message, Object... params) {
// return new RegraNegocioException(String.format(message, params)) {
// @Override
// public boolean equals(Object obj) {
// return RegraNegocioException.this == obj;
// }
// };
// }
//
// public RegraNegocioException thrownIf(boolean condition) throws RegraNegocioException {
// if (condition) {
// throw this;
// }
// return this;
// }
//
// }
|
import java.io.IOException;
import br.com.delogic.leitoor.exception.LeitoorException;
import br.com.delogic.leitoor.exception.RegraNegocioException;
import com.google.api.services.oauth2.model.Userinfoplus;
|
package br.com.delogic.leitoor.service;
public interface GoogleService {
/**
* Obtém a url de conexão com o Google
*
* @param convite
* @return uma url
*/
String getUrlAutenticacao(String convite);
/**
* Obtém um usuario GooglePlus
*
* @param code
* @return usuario google
* @throws IOException
* @throws LeitoorException
*/
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/LeitoorException.java
// @SuppressWarnings("serial")
// public class LeitoorException extends Exception {
//
// public LeitoorException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LeitoorException(String message) {
// super(message);
// }
//
// public static LeitoorException conviteInvalidoException(String convite) {
// return new LeitoorException("Este convite não possui validade em nosso sistema:" + convite);
// }
//
// public static LeitoorException contaInvalidaException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// public static LeitoorException autenticacaoException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/RegraNegocioException.java
// @SuppressWarnings("serial")
// public class RegraNegocioException extends ViolacaoException {
//
// public RegraNegocioException(String message) {
// super(message);
// }
//
// public RegraNegocioException() {
// super(null);
// }
//
// public static RegraNegocioException of(String message) {
// return new RegraNegocioException(message);
// }
//
// public RegraNegocioException withMessage(String message, Object... params) {
// return new RegraNegocioException(String.format(message, params)) {
// @Override
// public boolean equals(Object obj) {
// return RegraNegocioException.this == obj;
// }
// };
// }
//
// public RegraNegocioException thrownIf(boolean condition) throws RegraNegocioException {
// if (condition) {
// throw this;
// }
// return this;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/service/GoogleService.java
import java.io.IOException;
import br.com.delogic.leitoor.exception.LeitoorException;
import br.com.delogic.leitoor.exception.RegraNegocioException;
import com.google.api.services.oauth2.model.Userinfoplus;
package br.com.delogic.leitoor.service;
public interface GoogleService {
/**
* Obtém a url de conexão com o Google
*
* @param convite
* @return uma url
*/
String getUrlAutenticacao(String convite);
/**
* Obtém um usuario GooglePlus
*
* @param code
* @return usuario google
* @throws IOException
* @throws LeitoorException
*/
|
Userinfoplus getUsuarioGoogle(String code) throws LeitoorException;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/service/GoogleService.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/LeitoorException.java
// @SuppressWarnings("serial")
// public class LeitoorException extends Exception {
//
// public LeitoorException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LeitoorException(String message) {
// super(message);
// }
//
// public static LeitoorException conviteInvalidoException(String convite) {
// return new LeitoorException("Este convite não possui validade em nosso sistema:" + convite);
// }
//
// public static LeitoorException contaInvalidaException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// public static LeitoorException autenticacaoException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/RegraNegocioException.java
// @SuppressWarnings("serial")
// public class RegraNegocioException extends ViolacaoException {
//
// public RegraNegocioException(String message) {
// super(message);
// }
//
// public RegraNegocioException() {
// super(null);
// }
//
// public static RegraNegocioException of(String message) {
// return new RegraNegocioException(message);
// }
//
// public RegraNegocioException withMessage(String message, Object... params) {
// return new RegraNegocioException(String.format(message, params)) {
// @Override
// public boolean equals(Object obj) {
// return RegraNegocioException.this == obj;
// }
// };
// }
//
// public RegraNegocioException thrownIf(boolean condition) throws RegraNegocioException {
// if (condition) {
// throw this;
// }
// return this;
// }
//
// }
|
import java.io.IOException;
import br.com.delogic.leitoor.exception.LeitoorException;
import br.com.delogic.leitoor.exception.RegraNegocioException;
import com.google.api.services.oauth2.model.Userinfoplus;
|
package br.com.delogic.leitoor.service;
public interface GoogleService {
/**
* Obtém a url de conexão com o Google
*
* @param convite
* @return uma url
*/
String getUrlAutenticacao(String convite);
/**
* Obtém um usuario GooglePlus
*
* @param code
* @return usuario google
* @throws IOException
* @throws LeitoorException
*/
Userinfoplus getUsuarioGoogle(String code) throws LeitoorException;
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/LeitoorException.java
// @SuppressWarnings("serial")
// public class LeitoorException extends Exception {
//
// public LeitoorException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LeitoorException(String message) {
// super(message);
// }
//
// public static LeitoorException conviteInvalidoException(String convite) {
// return new LeitoorException("Este convite não possui validade em nosso sistema:" + convite);
// }
//
// public static LeitoorException contaInvalidaException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// public static LeitoorException autenticacaoException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/RegraNegocioException.java
// @SuppressWarnings("serial")
// public class RegraNegocioException extends ViolacaoException {
//
// public RegraNegocioException(String message) {
// super(message);
// }
//
// public RegraNegocioException() {
// super(null);
// }
//
// public static RegraNegocioException of(String message) {
// return new RegraNegocioException(message);
// }
//
// public RegraNegocioException withMessage(String message, Object... params) {
// return new RegraNegocioException(String.format(message, params)) {
// @Override
// public boolean equals(Object obj) {
// return RegraNegocioException.this == obj;
// }
// };
// }
//
// public RegraNegocioException thrownIf(boolean condition) throws RegraNegocioException {
// if (condition) {
// throw this;
// }
// return this;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/service/GoogleService.java
import java.io.IOException;
import br.com.delogic.leitoor.exception.LeitoorException;
import br.com.delogic.leitoor.exception.RegraNegocioException;
import com.google.api.services.oauth2.model.Userinfoplus;
package br.com.delogic.leitoor.service;
public interface GoogleService {
/**
* Obtém a url de conexão com o Google
*
* @param convite
* @return uma url
*/
String getUrlAutenticacao(String convite);
/**
* Obtém um usuario GooglePlus
*
* @param code
* @return usuario google
* @throws IOException
* @throws LeitoorException
*/
Userinfoplus getUsuarioGoogle(String code) throws LeitoorException;
|
RegraNegocioException ERRO_AUTENTICACAO_GOOGLE = new RegraNegocioException(
|
celiosilva/leitoor
|
leitoor/src/test/java/br/com/delogic/leitoor/SpringTeste.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/util/Log4jManager.java
// public class Log4jManager {
//
// public static void setLevel(Level level) {
// Logger root = Logger.getRootLogger();
// @SuppressWarnings("rawtypes")
// Enumeration allLoggers = root.getLoggerRepository().getCurrentCategories();
// root.setLevel(level);
// while (allLoggers.hasMoreElements()) {
// Category tmpLogger = (Category) allLoggers.nextElement();
// tmpLogger.setLevel(level);
// }
// }
//
// }
|
import javax.inject.Inject;
import org.apache.log4j.Level;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import br.com.delogic.csa.manager.EmailManager;
import br.com.delogic.csa.manager.email.EmailAddress;
import br.com.delogic.csa.manager.email.EmailContent;
import br.com.delogic.leitoor.util.Log4jManager;
|
package br.com.delogic.leitoor;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(value = {
"classpath:spring/application-beans.xml",
"classpath:spring/environment-beans.xml",
"classpath:spring/web-beans.xml"})
public class SpringTeste extends Assert {
static {
System.setProperty("spring.profiles.active", "TEST");
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/util/Log4jManager.java
// public class Log4jManager {
//
// public static void setLevel(Level level) {
// Logger root = Logger.getRootLogger();
// @SuppressWarnings("rawtypes")
// Enumeration allLoggers = root.getLoggerRepository().getCurrentCategories();
// root.setLevel(level);
// while (allLoggers.hasMoreElements()) {
// Category tmpLogger = (Category) allLoggers.nextElement();
// tmpLogger.setLevel(level);
// }
// }
//
// }
// Path: leitoor/src/test/java/br/com/delogic/leitoor/SpringTeste.java
import javax.inject.Inject;
import org.apache.log4j.Level;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import br.com.delogic.csa.manager.EmailManager;
import br.com.delogic.csa.manager.email.EmailAddress;
import br.com.delogic.csa.manager.email.EmailContent;
import br.com.delogic.leitoor.util.Log4jManager;
package br.com.delogic.leitoor;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(value = {
"classpath:spring/application-beans.xml",
"classpath:spring/environment-beans.xml",
"classpath:spring/web-beans.xml"})
public class SpringTeste extends Assert {
static {
System.setProperty("spring.profiles.active", "TEST");
|
Log4jManager.setLevel(Level.INFO);
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/service/impl/GoogleServiceImpl.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/LeitoorException.java
// @SuppressWarnings("serial")
// public class LeitoorException extends Exception {
//
// public LeitoorException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LeitoorException(String message) {
// super(message);
// }
//
// public static LeitoorException conviteInvalidoException(String convite) {
// return new LeitoorException("Este convite não possui validade em nosso sistema:" + convite);
// }
//
// public static LeitoorException contaInvalidaException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// public static LeitoorException autenticacaoException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/service/GoogleService.java
// public interface GoogleService {
//
// /**
// * Obtém a url de conexão com o Google
// *
// * @param convite
// * @return uma url
// */
// String getUrlAutenticacao(String convite);
//
// /**
// * Obtém um usuario GooglePlus
// *
// * @param code
// * @return usuario google
// * @throws IOException
// * @throws LeitoorException
// */
// Userinfoplus getUsuarioGoogle(String code) throws LeitoorException;
//
// RegraNegocioException ERRO_AUTENTICACAO_GOOGLE = new RegraNegocioException(
// "Aconteceu um erro ao tentar efetuar a autenticação");
// }
|
import java.io.IOException;
import javax.inject.Named;
import br.com.delogic.leitoor.exception.LeitoorException;
import br.com.delogic.leitoor.service.GoogleService;
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.oauth2.Oauth2;
import com.google.api.services.oauth2.model.Userinfoplus;
|
package br.com.delogic.leitoor.service.impl;
@Named("googleService")
public class GoogleServiceImpl implements GoogleService {
private static final String CLIENT_SECRET = "UDX_mDnc6Vy9GzG2Hf3vXKvF";
private static final String CLIENT_ID = "232471467258-nka1vthancampcs3raf6geaaojcgbhpv.apps.googleusercontent.com";
@Override
public String getUrlAutenticacao(String convite) {
return "redirect:https://accounts.google.com/o/oauth2/auth?"
+ "&client_id=" + CLIENT_ID
+ "&redirect_uri=http://leitoor.com.br/login/google/autenticar"
+ "&scope=email%20profile"
+ "&state=" + convite
+ "&response_type=code";
}
@Override
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/exception/LeitoorException.java
// @SuppressWarnings("serial")
// public class LeitoorException extends Exception {
//
// public LeitoorException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public LeitoorException(String message) {
// super(message);
// }
//
// public static LeitoorException conviteInvalidoException(String convite) {
// return new LeitoorException("Este convite não possui validade em nosso sistema:" + convite);
// }
//
// public static LeitoorException contaInvalidaException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// public static LeitoorException autenticacaoException(String mensagem) {
// return new LeitoorException(mensagem);
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/service/GoogleService.java
// public interface GoogleService {
//
// /**
// * Obtém a url de conexão com o Google
// *
// * @param convite
// * @return uma url
// */
// String getUrlAutenticacao(String convite);
//
// /**
// * Obtém um usuario GooglePlus
// *
// * @param code
// * @return usuario google
// * @throws IOException
// * @throws LeitoorException
// */
// Userinfoplus getUsuarioGoogle(String code) throws LeitoorException;
//
// RegraNegocioException ERRO_AUTENTICACAO_GOOGLE = new RegraNegocioException(
// "Aconteceu um erro ao tentar efetuar a autenticação");
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/service/impl/GoogleServiceImpl.java
import java.io.IOException;
import javax.inject.Named;
import br.com.delogic.leitoor.exception.LeitoorException;
import br.com.delogic.leitoor.service.GoogleService;
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeTokenRequest;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.auth.oauth2.GoogleTokenResponse;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.oauth2.Oauth2;
import com.google.api.services.oauth2.model.Userinfoplus;
package br.com.delogic.leitoor.service.impl;
@Named("googleService")
public class GoogleServiceImpl implements GoogleService {
private static final String CLIENT_SECRET = "UDX_mDnc6Vy9GzG2Hf3vXKvF";
private static final String CLIENT_ID = "232471467258-nka1vthancampcs3raf6geaaojcgbhpv.apps.googleusercontent.com";
@Override
public String getUrlAutenticacao(String convite) {
return "redirect:https://accounts.google.com/o/oauth2/auth?"
+ "&client_id=" + CLIENT_ID
+ "&redirect_uri=http://leitoor.com.br/login/google/autenticar"
+ "&scope=email%20profile"
+ "&state=" + convite
+ "&response_type=code";
}
@Override
|
public Userinfoplus getUsuarioGoogle(String codigo) throws LeitoorException {
|
celiosilva/leitoor
|
leitoor/src/test/java/br/com/delogic/leitoor/TestePdfSplit.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/repository/DocumentosRepository.java
// public interface DocumentosRepository {
//
// Map<Integer, String> dividirArquivo(String nomeArquivo);
//
// Map<Integer, String> dividirPdf(InputStream inputStream);
//
// }
|
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.junit.Ignore;
import org.junit.Test;
import br.com.delogic.csa.manager.ContentManager;
import br.com.delogic.leitoor.repository.DocumentosRepository;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
|
package br.com.delogic.leitoor;
public class TestePdfSplit extends SpringTeste {
@Inject
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/repository/DocumentosRepository.java
// public interface DocumentosRepository {
//
// Map<Integer, String> dividirArquivo(String nomeArquivo);
//
// Map<Integer, String> dividirPdf(InputStream inputStream);
//
// }
// Path: leitoor/src/test/java/br/com/delogic/leitoor/TestePdfSplit.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Inject;
import org.junit.Ignore;
import org.junit.Test;
import br.com.delogic.csa.manager.ContentManager;
import br.com.delogic.leitoor.repository.DocumentosRepository;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
package br.com.delogic.leitoor;
public class TestePdfSplit extends SpringTeste {
@Inject
|
private DocumentosRepository documentoRepository;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/model/DetalharLeituraAlunoModel.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
|
import java.util.Date;
import java.util.List;
import java.util.Map;
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
|
package br.com.delogic.leitoor.model;
public class DetalharLeituraAlunoModel {
private Aluno aluno;
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/model/DetalharLeituraAlunoModel.java
import java.util.Date;
import java.util.List;
import java.util.Map;
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
package br.com.delogic.leitoor.model;
public class DetalharLeituraAlunoModel {
private Aluno aluno;
|
private List<Leitura> leituras;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/model/DetalharLeituraAlunoModel.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
|
import java.util.Date;
import java.util.List;
import java.util.Map;
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
|
package br.com.delogic.leitoor.model;
public class DetalharLeituraAlunoModel {
private Aluno aluno;
private List<Leitura> leituras;
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/model/DetalharLeituraAlunoModel.java
import java.util.Date;
import java.util.List;
import java.util.Map;
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
package br.com.delogic.leitoor.model;
public class DetalharLeituraAlunoModel {
private Aluno aluno;
private List<Leitura> leituras;
|
private Atividade atividade;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/model/DetalharLeituraAlunoModel.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
|
import java.util.Date;
import java.util.List;
import java.util.Map;
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
|
package br.com.delogic.leitoor.model;
public class DetalharLeituraAlunoModel {
private Aluno aluno;
private List<Leitura> leituras;
private Atividade atividade;
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Atividade.java
// @Entity
// public class Atividade extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_atividade")
// @SequenceGenerator(name = "seq_atividade", sequenceName = "seq_atividade", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricao;
//
// @OneToOne
// private MaterialConfigurado materialConfigurado;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// public void setDescricao(String descricao) {
// this.descricao = descricao;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Leitura.java
// @Entity
// public class Leitura extends Identity<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_leitura")
// @SequenceGenerator(name = "seq_leitura", sequenceName = "seq_leitura", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @ManyToOne
// private TarefaEnviada tarefaEnviada;
//
// private Integer pagina;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataInicial;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date dataFinal;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public TarefaEnviada getTarefaEnviada() {
// return tarefaEnviada;
// }
//
// public void setTarefaEnviada(TarefaEnviada tarefaEnviada) {
// this.tarefaEnviada = tarefaEnviada;
// }
//
// public Integer getPagina() {
// return pagina;
// }
//
// public void setPagina(Integer pagina) {
// this.pagina = pagina;
// }
//
// public Date getDataInicial() {
// return dataInicial;
// }
//
// public void setDataInicial(Date dataInicial) {
// this.dataInicial = dataInicial;
// }
//
// public Date getDataFinal() {
// return dataFinal;
// }
//
// public void setDataFinal(Date dataFinal) {
// this.dataFinal = dataFinal;
// }
//
// }
//
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Tarefa.java
// @Entity
// public class Tarefa extends DominioProfessor<Integer> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_tarefa")
// @SequenceGenerator(name = "seq_tarefa", sequenceName = "seq_tarefa", allocationSize = 1, initialValue = 1)
// private Integer id;
//
// @Column(length = 50)
// private String descricaoAtividade;
//
// private Integer idAtividade;
//
// @ManyToOne
// private MaterialConfigurado materialConfigurado;
//
// @ManyToOne
// private Turma turma;
//
// public Integer getId() {
// return id;
// }
//
// public void setId(Integer id) {
// this.id = id;
// }
//
// public Turma getTurma() {
// return turma;
// }
//
// public void setTurma(Turma turma) {
// this.turma = turma;
// }
//
// public String getDescricaoAtividade() {
// return descricaoAtividade;
// }
//
// public void setDescricaoAtividade(String descricaoAtividade) {
// this.descricaoAtividade = descricaoAtividade;
// }
//
// public Integer getIdAtividade() {
// return idAtividade;
// }
//
// public void setIdAtividade(Integer idAtividade) {
// this.idAtividade = idAtividade;
// }
//
// public MaterialConfigurado getMaterialConfigurado() {
// return materialConfigurado;
// }
//
// public void setMaterialConfigurado(MaterialConfigurado materialConfigurado) {
// this.materialConfigurado = materialConfigurado;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/model/DetalharLeituraAlunoModel.java
import java.util.Date;
import java.util.List;
import java.util.Map;
import br.com.delogic.leitoor.entidade.Aluno;
import br.com.delogic.leitoor.entidade.Atividade;
import br.com.delogic.leitoor.entidade.Leitura;
import br.com.delogic.leitoor.entidade.Tarefa;
package br.com.delogic.leitoor.model;
public class DetalharLeituraAlunoModel {
private Aluno aluno;
private List<Leitura> leituras;
private Atividade atividade;
|
private Tarefa tarefa;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/entidade/mapped/DominioAluno.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
|
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import br.com.delogic.jfunk.data.Identity;
import br.com.delogic.leitoor.entidade.Aluno;
|
package br.com.delogic.leitoor.entidade.mapped;
@MappedSuperclass
public abstract class DominioAluno<E> extends Identity<E> {
@ManyToOne
@JoinColumn(nullable = false)
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Aluno.java
// @Entity
// @DiscriminatorValue("ALUNO")
// public class Aluno extends Usuario {
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/mapped/DominioAluno.java
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import br.com.delogic.jfunk.data.Identity;
import br.com.delogic.leitoor.entidade.Aluno;
package br.com.delogic.leitoor.entidade.mapped;
@MappedSuperclass
public abstract class DominioAluno<E> extends Identity<E> {
@ManyToOne
@JoinColumn(nullable = false)
|
private Aluno aluno;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/entidade/Resposta.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/enums/Avaliacao.java
// public enum Avaliacao {
//
// INCORRETO("Incorreto"), CORRETO("Correto");
//
// private final String descricao;
//
// private Avaliacao(String desc) {
// this.descricao = desc;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// }
|
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import br.com.delogic.jfunk.data.Identity;
import br.com.delogic.leitoor.entidade.enums.Avaliacao;
|
package br.com.delogic.leitoor.entidade;
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "TIPO", length = 50)
public abstract class Resposta extends Identity<Integer> {
public abstract String getAlternativaSelecionada();
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_resposta")
@SequenceGenerator(name = "seq_resposta", sequenceName = "seq_resposta", allocationSize = 1, initialValue = 1)
private Integer id;
@ManyToOne
private TarefaEnviada tarefaEnviada;
@ManyToOne
private Questao questao;
@Enumerated(EnumType.STRING)
@Column(length = 50)
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/enums/Avaliacao.java
// public enum Avaliacao {
//
// INCORRETO("Incorreto"), CORRETO("Correto");
//
// private final String descricao;
//
// private Avaliacao(String desc) {
// this.descricao = desc;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Resposta.java
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import br.com.delogic.jfunk.data.Identity;
import br.com.delogic.leitoor.entidade.enums.Avaliacao;
package br.com.delogic.leitoor.entidade;
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "TIPO", length = 50)
public abstract class Resposta extends Identity<Integer> {
public abstract String getAlternativaSelecionada();
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_resposta")
@SequenceGenerator(name = "seq_resposta", sequenceName = "seq_resposta", allocationSize = 1, initialValue = 1)
private Integer id;
@ManyToOne
private TarefaEnviada tarefaEnviada;
@ManyToOne
private Questao questao;
@Enumerated(EnumType.STRING)
@Column(length = 50)
|
private Avaliacao avaliacao;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/entidade/mapped/DominioProfessor.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Professor.java
// @Entity
// @DiscriminatorValue("PROFESSOR")
// public class Professor extends Aluno {
//
// }
|
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import br.com.delogic.jfunk.data.Identity;
import br.com.delogic.leitoor.entidade.Professor;
|
package br.com.delogic.leitoor.entidade.mapped;
@MappedSuperclass
public abstract class DominioProfessor<E> extends Identity<E> {
@ManyToOne
@JoinColumn(nullable = false)
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/Professor.java
// @Entity
// @DiscriminatorValue("PROFESSOR")
// public class Professor extends Aluno {
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/mapped/DominioProfessor.java
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import br.com.delogic.jfunk.data.Identity;
import br.com.delogic.leitoor.entidade.Professor;
package br.com.delogic.leitoor.entidade.mapped;
@MappedSuperclass
public abstract class DominioProfessor<E> extends Identity<E> {
@ManyToOne
@JoinColumn(nullable = false)
|
private Professor professor;
|
celiosilva/leitoor
|
leitoor/src/main/java/br/com/delogic/leitoor/model/AvaliacaoQuestionarioModel.java
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/enums/Avaliacao.java
// public enum Avaliacao {
//
// INCORRETO("Incorreto"), CORRETO("Correto");
//
// private final String descricao;
//
// private Avaliacao(String desc) {
// this.descricao = desc;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// }
|
import java.util.List;
import br.com.delogic.leitoor.entidade.enums.Avaliacao;
|
package br.com.delogic.leitoor.model;
public class AvaliacaoQuestionarioModel {
public static class RespostaModel {
private Integer id;
private String questao;
private String resposta;
|
// Path: leitoor/src/main/java/br/com/delogic/leitoor/entidade/enums/Avaliacao.java
// public enum Avaliacao {
//
// INCORRETO("Incorreto"), CORRETO("Correto");
//
// private final String descricao;
//
// private Avaliacao(String desc) {
// this.descricao = desc;
// }
//
// public String getDescricao() {
// return descricao;
// }
//
// }
// Path: leitoor/src/main/java/br/com/delogic/leitoor/model/AvaliacaoQuestionarioModel.java
import java.util.List;
import br.com.delogic.leitoor.entidade.enums.Avaliacao;
package br.com.delogic.leitoor.model;
public class AvaliacaoQuestionarioModel {
public static class RespostaModel {
private Integer id;
private String questao;
private String resposta;
|
private Avaliacao avaliacao;
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/aboutTmc/AboutTmcDialog.java
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/errors/ErrorMessageService.java
// public class ErrorMessageService {
//
// /**
// * Notification group used by IntelliJ to group TMC notifications.
// */
// public static final NotificationGroup TMC_NOTIFICATION = new NotificationGroup(
// "TMC Error Messages",
// NotificationDisplayType.STICKY_BALLOON,
// true
// );
//
// private static final Logger logger = LoggerFactory.getLogger(ErrorMessageService.class);
//
// public void showInfoBalloon(String message) {
// showBalloonNotification(message, NotificationType.INFORMATION);
// }
//
// public void showExercisesAreUpToDate(Course course) {
// ApplicationManager.getApplication().invokeLater(() -> Messages.showMessageDialog(
// "All exercises for " + course.toString() + " are up to date.",
// "All Exercises Are up to Date.",
// Messages.getInformationIcon()
// ));
// }
//
// public void showPopupWithDetails(String message,
// String title,
// String details,
// NotificationType notificationType) {
// Project currentProject = new ObjectFinder().findCurrentProject();
// Icon icon = iconForNotificationType(notificationType);
//
// ApplicationManager.getApplication().invokeLater(() -> Messages.showDialog(
// currentProject,
// message,
// title,
// details,
// new String[] { Messages.OK_BUTTON },
// 0,
// 0,
// icon
// ));
// }
//
// /**
// * Shows a human readable error message to the user as a popup or a notification balloon.
// *
// * @param coreException The cause of the error.
// * @param showAsPopup if the error message will be a pop up or not.
// */
// public void showHumanReadableErrorMessage(TmcCoreException coreException, boolean showAsPopup) {
// logger.info("Showing human readable TmcCoreException. {} @ErrorMessageService", coreException);
// PresentableErrorMessage content = PresentableErrorMessage.forTmcException(coreException);
// showNotification(content.getMessage(), content.getMessageType(), showAsPopup);
// }
//
// /**
// * Shows an error message to the user as a popup or a notification balloon.
// *
// * @param exception The cause of the error, prepended to the description.
// * @param errorDescription Additional description of the error.
// * @param showAsPopup if the error message will be a pop up or not.
// */
// public void showErrorMessageWithExceptionDetails(Exception exception,
// String errorDescription,
// boolean showAsPopup) {
// logger.info("Showing Exception. {} @ErrorMessageService", exception);
// String message = exception + ". \n" + errorDescription;
// showNotification(message, NotificationType.ERROR, showAsPopup);
// }
//
// public void showErrorMessagePopup(String errorMessage) {
// logger.info("Showing error message: {}. @ErrorMessageService", errorMessage);
// showNotification(errorMessage, NotificationType.ERROR, true);
// }
//
// private void showNotification(String message, NotificationType type, boolean showAsPopup) {
// if (showAsPopup) {
// showPopup(message, type);
// } else {
// showBalloonNotification(message, type);
// }
// }
//
// private void showBalloonNotification(String message, NotificationType type) {
// Notification notification = TMC_NOTIFICATION.createNotification(message, type);
// Project currentProject = new ObjectFinder().findCurrentProject();
//
// ApplicationManager.getApplication().invokeLater(() -> Notifications.Bus.notify(notification, currentProject));
// }
//
// private void showPopup(String message, NotificationType notificationType) {
// Project currentProject = new ObjectFinder().findCurrentProject();
// Icon icon = iconForNotificationType(notificationType);
//
// ApplicationManager.getApplication().invokeLater(() -> Messages.showMessageDialog(currentProject, message, "", icon));
// }
//
// private Icon iconForNotificationType(NotificationType type) {
// if (type == NotificationType.WARNING) {
// return Messages.getWarningIcon();
// } else if (type == NotificationType.ERROR) {
// return Messages.getErrorIcon();
// } else if (type == NotificationType.INFORMATION) {
// return Messages.getInformationIcon();
// } else {
// return Messages.getErrorIcon();
// }
// }
// }
|
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.ui.components.JBScrollPane;
import fi.helsinki.cs.tmc.intellij.services.errors.ErrorMessageService;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;
|
public static void display() {
AboutTmcDialog dialog = new AboutTmcDialog();
dialog.setLocationRelativeTo(null);
dialog.setTitle("About");
dialog.setVisible(true);
dialog.setAlwaysOnTop(true);
}
public AboutTmcDialog() {
super(
WindowManager.getInstance()
.getFrame(ProjectManager.getInstance().getDefaultProject()),
false);
initComponents();
this.headerLabel.setText("About Test My Code");
this.infoTextPane.setText("<html> <body> <div> Test My Code is a service designed for learning and teaching programming. It is open "
+ "source, provides support for automatic assessment of programming assignments, and comes with a server "
+ "that can be used to maintain course-specific point lists and grading. </div> <br> <div> "
+ "Find out more at <a href=\"https://mooc.fi/tmc\">https://mooc.fi/tmc</a>. </div> </body> </html>");
this.closeButton.setText("Close");
this.infoTextPane.addHyperlinkListener((HyperlinkEvent e) -> {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
Desktop desktop = Desktop.getDesktop();
desktop.browse(new URI("https://mooc.fi/tmc"));
} catch (Exception ex) {
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/errors/ErrorMessageService.java
// public class ErrorMessageService {
//
// /**
// * Notification group used by IntelliJ to group TMC notifications.
// */
// public static final NotificationGroup TMC_NOTIFICATION = new NotificationGroup(
// "TMC Error Messages",
// NotificationDisplayType.STICKY_BALLOON,
// true
// );
//
// private static final Logger logger = LoggerFactory.getLogger(ErrorMessageService.class);
//
// public void showInfoBalloon(String message) {
// showBalloonNotification(message, NotificationType.INFORMATION);
// }
//
// public void showExercisesAreUpToDate(Course course) {
// ApplicationManager.getApplication().invokeLater(() -> Messages.showMessageDialog(
// "All exercises for " + course.toString() + " are up to date.",
// "All Exercises Are up to Date.",
// Messages.getInformationIcon()
// ));
// }
//
// public void showPopupWithDetails(String message,
// String title,
// String details,
// NotificationType notificationType) {
// Project currentProject = new ObjectFinder().findCurrentProject();
// Icon icon = iconForNotificationType(notificationType);
//
// ApplicationManager.getApplication().invokeLater(() -> Messages.showDialog(
// currentProject,
// message,
// title,
// details,
// new String[] { Messages.OK_BUTTON },
// 0,
// 0,
// icon
// ));
// }
//
// /**
// * Shows a human readable error message to the user as a popup or a notification balloon.
// *
// * @param coreException The cause of the error.
// * @param showAsPopup if the error message will be a pop up or not.
// */
// public void showHumanReadableErrorMessage(TmcCoreException coreException, boolean showAsPopup) {
// logger.info("Showing human readable TmcCoreException. {} @ErrorMessageService", coreException);
// PresentableErrorMessage content = PresentableErrorMessage.forTmcException(coreException);
// showNotification(content.getMessage(), content.getMessageType(), showAsPopup);
// }
//
// /**
// * Shows an error message to the user as a popup or a notification balloon.
// *
// * @param exception The cause of the error, prepended to the description.
// * @param errorDescription Additional description of the error.
// * @param showAsPopup if the error message will be a pop up or not.
// */
// public void showErrorMessageWithExceptionDetails(Exception exception,
// String errorDescription,
// boolean showAsPopup) {
// logger.info("Showing Exception. {} @ErrorMessageService", exception);
// String message = exception + ". \n" + errorDescription;
// showNotification(message, NotificationType.ERROR, showAsPopup);
// }
//
// public void showErrorMessagePopup(String errorMessage) {
// logger.info("Showing error message: {}. @ErrorMessageService", errorMessage);
// showNotification(errorMessage, NotificationType.ERROR, true);
// }
//
// private void showNotification(String message, NotificationType type, boolean showAsPopup) {
// if (showAsPopup) {
// showPopup(message, type);
// } else {
// showBalloonNotification(message, type);
// }
// }
//
// private void showBalloonNotification(String message, NotificationType type) {
// Notification notification = TMC_NOTIFICATION.createNotification(message, type);
// Project currentProject = new ObjectFinder().findCurrentProject();
//
// ApplicationManager.getApplication().invokeLater(() -> Notifications.Bus.notify(notification, currentProject));
// }
//
// private void showPopup(String message, NotificationType notificationType) {
// Project currentProject = new ObjectFinder().findCurrentProject();
// Icon icon = iconForNotificationType(notificationType);
//
// ApplicationManager.getApplication().invokeLater(() -> Messages.showMessageDialog(currentProject, message, "", icon));
// }
//
// private Icon iconForNotificationType(NotificationType type) {
// if (type == NotificationType.WARNING) {
// return Messages.getWarningIcon();
// } else if (type == NotificationType.ERROR) {
// return Messages.getErrorIcon();
// } else if (type == NotificationType.INFORMATION) {
// return Messages.getInformationIcon();
// } else {
// return Messages.getErrorIcon();
// }
// }
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/aboutTmc/AboutTmcDialog.java
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.ui.components.JBScrollPane;
import fi.helsinki.cs.tmc.intellij.services.errors.ErrorMessageService;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;
public static void display() {
AboutTmcDialog dialog = new AboutTmcDialog();
dialog.setLocationRelativeTo(null);
dialog.setTitle("About");
dialog.setVisible(true);
dialog.setAlwaysOnTop(true);
}
public AboutTmcDialog() {
super(
WindowManager.getInstance()
.getFrame(ProjectManager.getInstance().getDefaultProject()),
false);
initComponents();
this.headerLabel.setText("About Test My Code");
this.infoTextPane.setText("<html> <body> <div> Test My Code is a service designed for learning and teaching programming. It is open "
+ "source, provides support for automatic assessment of programming assignments, and comes with a server "
+ "that can be used to maintain course-specific point lists and grading. </div> <br> <div> "
+ "Find out more at <a href=\"https://mooc.fi/tmc\">https://mooc.fi/tmc</a>. </div> </body> </html>");
this.closeButton.setText("Close");
this.infoTextPane.addHyperlinkListener((HyperlinkEvent e) -> {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
Desktop desktop = Desktop.getDesktop();
desktop.browse(new URI("https://mooc.fi/tmc"));
} catch (Exception ex) {
|
new ErrorMessageService().showErrorMessagePopup("Failed to open browser.\n" + ex.getMessage());
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/ThreadingService.java
|
// Path: tmc-plugin-intellij/src/test/java/com/intellij/openapi/progress/util/ProgressWindow.java
// public interface ProgressWindow {
// }
|
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.util.ProgressWindow;
import com.intellij.openapi.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
package fi.helsinki.cs.tmc.intellij.services;
public class ThreadingService {
private static final Logger logger = LoggerFactory.getLogger(ThreadingService.class);
public void runWithNotification(
|
// Path: tmc-plugin-intellij/src/test/java/com/intellij/openapi/progress/util/ProgressWindow.java
// public interface ProgressWindow {
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/ThreadingService.java
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.util.ProgressWindow;
import com.intellij.openapi.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package fi.helsinki.cs.tmc.intellij.services;
public class ThreadingService {
private static final Logger logger = LoggerFactory.getLogger(ThreadingService.class);
public void runWithNotification(
|
final Runnable run, Project project, ProgressWindow progressWindow) {
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/pastebin/ResultPanel.java
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/ClipboardService.java
// public class ClipboardService {
//
// private static final Logger logger = LoggerFactory.getLogger(ClipboardService.class);
//
// public static void copyToClipBoard(String stringToCopy) {
// logger.info("Copying {} to the clip board. @ClipboardService", stringToCopy);
// Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
// StringSelection selection = new StringSelection(stringToCopy);
// clipboard.setContents(selection, null);
// }
//
// public static String getClipBoard() {
// return ClipboardUtil.getTextInClipboard();
// }
// }
|
import fi.helsinki.cs.tmc.intellij.services.ClipboardService;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import com.intellij.util.ui.JBUI;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
|
package fi.helsinki.cs.tmc.intellij.ui.pastebin;
/**
* Creates the Pastebin result panel.
*/
public class ResultPanel {
private JTextField textField1;
private JButton viewPasteButton;
private JButton copyToClipboardButton;
private JButton okButton;
private JPanel jpanel1;
public ResultPanel(final URI uri, final PasteWindow pasteWindow) {
okButton.addActionListener(
event -> pasteWindow.close());
viewPasteButton.addActionListener(
event -> {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e1) {
e1.printStackTrace();
}
});
copyToClipboardButton.addActionListener(
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/ClipboardService.java
// public class ClipboardService {
//
// private static final Logger logger = LoggerFactory.getLogger(ClipboardService.class);
//
// public static void copyToClipBoard(String stringToCopy) {
// logger.info("Copying {} to the clip board. @ClipboardService", stringToCopy);
// Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
// StringSelection selection = new StringSelection(stringToCopy);
// clipboard.setContents(selection, null);
// }
//
// public static String getClipBoard() {
// return ClipboardUtil.getTextInClipboard();
// }
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/pastebin/ResultPanel.java
import fi.helsinki.cs.tmc.intellij.services.ClipboardService;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import com.intellij.util.ui.JBUI;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
package fi.helsinki.cs.tmc.intellij.ui.pastebin;
/**
* Creates the Pastebin result panel.
*/
public class ResultPanel {
private JTextField textField1;
private JButton viewPasteButton;
private JButton copyToClipboardButton;
private JButton okButton;
private JPanel jpanel1;
public ResultPanel(final URI uri, final PasteWindow pasteWindow) {
okButton.addActionListener(
event -> pasteWindow.close());
viewPasteButton.addActionListener(
event -> {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e1) {
e1.printStackTrace();
}
});
copyToClipboardButton.addActionListener(
|
event -> ClipboardService.copyToClipBoard(textField1.getText()));
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/actions/buttonactions/SubmitPasteAction.java
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/snapshots/ButtonInputListener.java
// public class ButtonInputListener {
//
// private static final Logger logger = LoggerFactory.getLogger(ButtonInputListener.class);
//
// public void receiveTestRun() {
// sendProjectActionEvent(getExercise(), "tmc.test");
// }
//
// public void receiveSubmit() {
// sendProjectActionEvent(getExercise(), "tmc.submit");
// }
//
// @Nullable
// private Exercise getExercise() {
// logger.info("Making sure current exercise should be tracked");
// if (new CourseAndExerciseManager()
// .isCourseInDatabase(
// PathResolver.getCourseName(
// new ObjectFinder().findCurrentProject().getBasePath()))) {
// return PathResolver.getExercise(new ObjectFinder().findCurrentProject().getBasePath());
// }
// return null;
// }
//
// public void receiveRunAction() {
// sendProjectActionEvent(getExercise(), "COMMAND_RUN");
// }
//
// public void receiveDebugRunAction() {
// sendProjectActionEvent(getExercise(), "COMMAND_DEBUG");
// }
//
// public void receivePastebin() {
// sendProjectActionEvent(getExercise(), "tmc.paste");
// }
//
// public void receiveDownloadExercise() {
// sendProjectActionEvent(getExercise(), "tmc.download_exercise");
// }
//
// public void receiveSettings() {
// sendProjectActionEvent("tmc.settings_saved");
// }
//
// private void sendProjectActionEvent(String command) {
// logger.info("Creating a project action event JSON.");
// Object data = Collections.singletonMap("command", command);
// String json = new Gson().toJson(data);
// byte[] jsonBytes = json.getBytes(Charset.forName("UTF-8"));
// LoggableEvent event = new LoggableEvent("ide_action", jsonBytes);
// addEvent(event);
// }
//
// private void sendProjectActionEvent(Exercise ex, String command) {
// if (ex == null) {
// logger.warn("Exercise was invalid.");
// return;
// }
//
// logger.info("Creating a project action event JSON.");
// Object data = Collections.singletonMap("command", command);
// String json = new Gson().toJson(data);
//
// byte[] jsonBytes = json.getBytes(Charset.forName("UTF-8"));
// LoggableEvent event = new LoggableEvent(ex, "project_action", jsonBytes);
// addEvent(event);
// }
//
// private void addEvent(LoggableEvent event) {
// logger.info("Checking that snapshots setting is enabled.");
// SnapshotsEventManager.add(event);
// }
// }
|
import fi.helsinki.cs.tmc.intellij.holders.TmcCoreHolder;
import fi.helsinki.cs.tmc.intellij.services.PasteService;
import fi.helsinki.cs.tmc.intellij.snapshots.ButtonInputListener;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
package fi.helsinki.cs.tmc.intellij.actions.buttonactions;
/**
* Defined in plugin.xml on line <action id="Submit to Pastebin"
* class="fi.helsinki.cs.tmc.intellij.actions.buttonactions.SubmitPasteAction"> in group actions
*
* <p>Submit code to TMC Pastebin.
*/
public class SubmitPasteAction extends AnAction {
private static final Logger logger = LoggerFactory.getLogger(SubmitPasteAction.class);
private PasteService pasteService;
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
logger.info("Performing SubmitPasteAction. @SubmitPasteAction");
paste(anActionEvent);
}
private void paste(AnActionEvent anActionEvent) {
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/snapshots/ButtonInputListener.java
// public class ButtonInputListener {
//
// private static final Logger logger = LoggerFactory.getLogger(ButtonInputListener.class);
//
// public void receiveTestRun() {
// sendProjectActionEvent(getExercise(), "tmc.test");
// }
//
// public void receiveSubmit() {
// sendProjectActionEvent(getExercise(), "tmc.submit");
// }
//
// @Nullable
// private Exercise getExercise() {
// logger.info("Making sure current exercise should be tracked");
// if (new CourseAndExerciseManager()
// .isCourseInDatabase(
// PathResolver.getCourseName(
// new ObjectFinder().findCurrentProject().getBasePath()))) {
// return PathResolver.getExercise(new ObjectFinder().findCurrentProject().getBasePath());
// }
// return null;
// }
//
// public void receiveRunAction() {
// sendProjectActionEvent(getExercise(), "COMMAND_RUN");
// }
//
// public void receiveDebugRunAction() {
// sendProjectActionEvent(getExercise(), "COMMAND_DEBUG");
// }
//
// public void receivePastebin() {
// sendProjectActionEvent(getExercise(), "tmc.paste");
// }
//
// public void receiveDownloadExercise() {
// sendProjectActionEvent(getExercise(), "tmc.download_exercise");
// }
//
// public void receiveSettings() {
// sendProjectActionEvent("tmc.settings_saved");
// }
//
// private void sendProjectActionEvent(String command) {
// logger.info("Creating a project action event JSON.");
// Object data = Collections.singletonMap("command", command);
// String json = new Gson().toJson(data);
// byte[] jsonBytes = json.getBytes(Charset.forName("UTF-8"));
// LoggableEvent event = new LoggableEvent("ide_action", jsonBytes);
// addEvent(event);
// }
//
// private void sendProjectActionEvent(Exercise ex, String command) {
// if (ex == null) {
// logger.warn("Exercise was invalid.");
// return;
// }
//
// logger.info("Creating a project action event JSON.");
// Object data = Collections.singletonMap("command", command);
// String json = new Gson().toJson(data);
//
// byte[] jsonBytes = json.getBytes(Charset.forName("UTF-8"));
// LoggableEvent event = new LoggableEvent(ex, "project_action", jsonBytes);
// addEvent(event);
// }
//
// private void addEvent(LoggableEvent event) {
// logger.info("Checking that snapshots setting is enabled.");
// SnapshotsEventManager.add(event);
// }
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/actions/buttonactions/SubmitPasteAction.java
import fi.helsinki.cs.tmc.intellij.holders.TmcCoreHolder;
import fi.helsinki.cs.tmc.intellij.services.PasteService;
import fi.helsinki.cs.tmc.intellij.snapshots.ButtonInputListener;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package fi.helsinki.cs.tmc.intellij.actions.buttonactions;
/**
* Defined in plugin.xml on line <action id="Submit to Pastebin"
* class="fi.helsinki.cs.tmc.intellij.actions.buttonactions.SubmitPasteAction"> in group actions
*
* <p>Submit code to TMC Pastebin.
*/
public class SubmitPasteAction extends AnAction {
private static final Logger logger = LoggerFactory.getLogger(SubmitPasteAction.class);
private PasteService pasteService;
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
logger.info("Performing SubmitPasteAction. @SubmitPasteAction");
paste(anActionEvent);
}
private void paste(AnActionEvent anActionEvent) {
|
new ButtonInputListener().receivePastebin();
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/organizationselection/OrganizationCard.java
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/holders/TmcSettingsManager.java
// public final class TmcSettingsManager {
//
// private static final Logger logger = LoggerFactory.getLogger(TmcSettingsManager.class);
// private static final PersistentTmcSettings persistentSettings =
// ServiceManager.getService(PersistentTmcSettings.class);
//
// private TmcSettingsManager() {}
//
// public static synchronized SettingsTmc get() {
// logger.info("Get SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// return persistentSettings.getSettingsTmc();
// }
//
// public static synchronized void setup() {
// logger.info("Setup SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// }
// }
|
import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBList;
import com.intellij.ui.components.JBScrollPane;
import fi.helsinki.cs.tmc.core.domain.Organization;
import fi.helsinki.cs.tmc.intellij.holders.TmcSettingsManager;
import javax.swing.*;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
|
information = information.substring(0, 187) + "...";
}
this.organizationInformation.setText(information);
this.organizationSlug.setText("/" + organization.getSlug());
setLogo();
}
private void setLogo() {
setLogo(logoUrl("placeholderLogo.png"));
final String logoPath = organization.getLogoPath();
if(!logoPath.contains("missing")) {
new Thread(() -> {
setLogo(logoUrl(logoPath));
this.parent.repaint();
}).start();
}
}
private void setLogo(URL logoUrl) {
this.image = new ImageIcon(logoUrl);
this.image.setImage(this.image.getImage().getScaledInstance(49, 49, Image.SCALE_SMOOTH));
this.logo.setIcon(this.image);
}
public Organization getOrganization() {
return this.organization;
}
private URL logoUrl(String path) {
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/holders/TmcSettingsManager.java
// public final class TmcSettingsManager {
//
// private static final Logger logger = LoggerFactory.getLogger(TmcSettingsManager.class);
// private static final PersistentTmcSettings persistentSettings =
// ServiceManager.getService(PersistentTmcSettings.class);
//
// private TmcSettingsManager() {}
//
// public static synchronized SettingsTmc get() {
// logger.info("Get SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// return persistentSettings.getSettingsTmc();
// }
//
// public static synchronized void setup() {
// logger.info("Setup SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// }
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/organizationselection/OrganizationCard.java
import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBList;
import com.intellij.ui.components.JBScrollPane;
import fi.helsinki.cs.tmc.core.domain.Organization;
import fi.helsinki.cs.tmc.intellij.holders.TmcSettingsManager;
import javax.swing.*;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
information = information.substring(0, 187) + "...";
}
this.organizationInformation.setText(information);
this.organizationSlug.setText("/" + organization.getSlug());
setLogo();
}
private void setLogo() {
setLogo(logoUrl("placeholderLogo.png"));
final String logoPath = organization.getLogoPath();
if(!logoPath.contains("missing")) {
new Thread(() -> {
setLogo(logoUrl(logoPath));
this.parent.repaint();
}).start();
}
}
private void setLogo(URL logoUrl) {
this.image = new ImageIcon(logoUrl);
this.image.setImage(this.image.getImage().getScaledInstance(49, 49, Image.SCALE_SMOOTH));
this.logo.setIcon(this.image);
}
public Organization getOrganization() {
return this.organization;
}
private URL logoUrl(String path) {
|
final String address = TmcSettingsManager.get().getServerAddress();
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/errors/PresentableErrorMessage.java
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/holders/TmcSettingsManager.java
// public final class TmcSettingsManager {
//
// private static final Logger logger = LoggerFactory.getLogger(TmcSettingsManager.class);
// private static final PersistentTmcSettings persistentSettings =
// ServiceManager.getService(PersistentTmcSettings.class);
//
// private TmcSettingsManager() {}
//
// public static synchronized SettingsTmc get() {
// logger.info("Get SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// return persistentSettings.getSettingsTmc();
// }
//
// public static synchronized void setup() {
// logger.info("Setup SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// }
// }
|
import fi.helsinki.cs.tmc.core.exceptions.TmcCoreException;
import fi.helsinki.cs.tmc.intellij.holders.TmcSettingsManager;
import com.intellij.notification.NotificationType;
|
package fi.helsinki.cs.tmc.intellij.services.errors;
class PresentableErrorMessage {
private final String message;
private final NotificationType messageType;
private PresentableErrorMessage(String message, NotificationType messageType) {
this.message = message;
this.messageType = messageType;
}
String getMessage() {
return message;
}
NotificationType getMessageType() {
return messageType;
}
/**
* Generates a human readable error message for a {@link TmcCoreException} and decides the
* error's severity.
*/
static PresentableErrorMessage forTmcException(TmcCoreException exception) {
String causeMessage;
causeMessage = exception.getMessage();
String shownMessage;
NotificationType type = NotificationType.WARNING;
if (causeMessage.contains("Download failed")
|| causeMessage.contains("404")
|| causeMessage.contains("500")) {
shownMessage = notifyAboutCourseServerAddressAndInternet();
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/holders/TmcSettingsManager.java
// public final class TmcSettingsManager {
//
// private static final Logger logger = LoggerFactory.getLogger(TmcSettingsManager.class);
// private static final PersistentTmcSettings persistentSettings =
// ServiceManager.getService(PersistentTmcSettings.class);
//
// private TmcSettingsManager() {}
//
// public static synchronized SettingsTmc get() {
// logger.info("Get SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// return persistentSettings.getSettingsTmc();
// }
//
// public static synchronized void setup() {
// logger.info("Setup SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// }
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/errors/PresentableErrorMessage.java
import fi.helsinki.cs.tmc.core.exceptions.TmcCoreException;
import fi.helsinki.cs.tmc.intellij.holders.TmcSettingsManager;
import com.intellij.notification.NotificationType;
package fi.helsinki.cs.tmc.intellij.services.errors;
class PresentableErrorMessage {
private final String message;
private final NotificationType messageType;
private PresentableErrorMessage(String message, NotificationType messageType) {
this.message = message;
this.messageType = messageType;
}
String getMessage() {
return message;
}
NotificationType getMessageType() {
return messageType;
}
/**
* Generates a human readable error message for a {@link TmcCoreException} and decides the
* error's severity.
*/
static PresentableErrorMessage forTmcException(TmcCoreException exception) {
String causeMessage;
causeMessage = exception.getMessage();
String shownMessage;
NotificationType type = NotificationType.WARNING;
if (causeMessage.contains("Download failed")
|| causeMessage.contains("404")
|| causeMessage.contains("500")) {
shownMessage = notifyAboutCourseServerAddressAndInternet();
|
} else if (!TmcSettingsManager.get().userDataExists()) {
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/actions/buttonactions/RunProjectAction.java
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/runners/RunProject.java
// public class RunProject {
//
// private static final Logger logger = LoggerFactory.getLogger(RunProject.class);
//
// private final RunConfigurationFactory factory;
//
// public RunProject(RunManager runManager, Module module, String configurationType) {
// logger.info("Creating RunConfigurationFactory.");
// factory = new RunConfigurationFactory(runManager, module, configurationType);
// if (makeSureConfigurationIsCorrectType(runManager)) {
// return;
// }
// factory.createRunner();
// }
//
// private boolean makeSureConfigurationIsCorrectType(RunManager runManager) {
// if (runManager.getSelectedConfiguration() == null || factory.checkConfigurationType()) {
// logger.info("Prompting user to choose main class with Chooser.");
// TreeClassChooser chooser = factory.chooseMainClassForProject();
// if (chooser.getSelected() == null) {
// logger.warn("Choosing main class returned null and running is cancelled.");
// return true;
// }
// logger.info("Creating configurations.");
// factory.createConfiguration();
// factory.configApplicationConfiguration(chooser);
// }
// return false;
// }
// }
|
import fi.helsinki.cs.tmc.intellij.runners.RunProject;
import com.intellij.execution.RunManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
package fi.helsinki.cs.tmc.intellij.actions.buttonactions;
public class RunProjectAction extends AnAction {
private static final Logger logger = LoggerFactory.getLogger(RunProjectAction.class);
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
runProject(anActionEvent.getProject());
}
/**
* Main run method, readies project module for running. First it finds current module, then
* checks, whether it has a valid runconfiguration or not. If it does not, it creates one,
* otherwise current configuration is run as is as long as it has a main class.
*/
private void runProject(Project project) {
logger.info("Run project action called.");
logger.info("Getting RunManager.");
RunManager runManager = RunManager.getInstance(project);
Module module = getModule(project);
String configurationType = getConfigurationType();
logger.info("Creating RunProject object.");
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/runners/RunProject.java
// public class RunProject {
//
// private static final Logger logger = LoggerFactory.getLogger(RunProject.class);
//
// private final RunConfigurationFactory factory;
//
// public RunProject(RunManager runManager, Module module, String configurationType) {
// logger.info("Creating RunConfigurationFactory.");
// factory = new RunConfigurationFactory(runManager, module, configurationType);
// if (makeSureConfigurationIsCorrectType(runManager)) {
// return;
// }
// factory.createRunner();
// }
//
// private boolean makeSureConfigurationIsCorrectType(RunManager runManager) {
// if (runManager.getSelectedConfiguration() == null || factory.checkConfigurationType()) {
// logger.info("Prompting user to choose main class with Chooser.");
// TreeClassChooser chooser = factory.chooseMainClassForProject();
// if (chooser.getSelected() == null) {
// logger.warn("Choosing main class returned null and running is cancelled.");
// return true;
// }
// logger.info("Creating configurations.");
// factory.createConfiguration();
// factory.configApplicationConfiguration(chooser);
// }
// return false;
// }
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/actions/buttonactions/RunProjectAction.java
import fi.helsinki.cs.tmc.intellij.runners.RunProject;
import com.intellij.execution.RunManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package fi.helsinki.cs.tmc.intellij.actions.buttonactions;
public class RunProjectAction extends AnAction {
private static final Logger logger = LoggerFactory.getLogger(RunProjectAction.class);
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
runProject(anActionEvent.getProject());
}
/**
* Main run method, readies project module for running. First it finds current module, then
* checks, whether it has a valid runconfiguration or not. If it does not, it creates one,
* otherwise current configuration is run as is as long as it has a main class.
*/
private void runProject(Project project) {
logger.info("Run project action called.");
logger.info("Getting RunManager.");
RunManager runManager = RunManager.getInstance(project);
Module module = getModule(project);
String configurationType = getConfigurationType();
logger.info("Creating RunProject object.");
|
new RunProject(runManager, module, configurationType);
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/actions/buttonactions/TmcSettingsAction.java
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/holders/TmcSettingsManager.java
// public final class TmcSettingsManager {
//
// private static final Logger logger = LoggerFactory.getLogger(TmcSettingsManager.class);
// private static final PersistentTmcSettings persistentSettings =
// ServiceManager.getService(PersistentTmcSettings.class);
//
// private TmcSettingsManager() {}
//
// public static synchronized SettingsTmc get() {
// logger.info("Get SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// return persistentSettings.getSettingsTmc();
// }
//
// public static synchronized void setup() {
// logger.info("Setup SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// }
// }
|
import fi.helsinki.cs.tmc.intellij.holders.TmcSettingsManager;
import fi.helsinki.cs.tmc.intellij.ui.login.LoginDialog;
import fi.helsinki.cs.tmc.intellij.ui.settings.SettingsWindow;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
package fi.helsinki.cs.tmc.intellij.actions.buttonactions;
/**
* Opens the settings window. Defined in plugin.xml on line <action id="Settings"
* class="fi.helsinki.cs.tmc.intellij .actions.buttonactions.TmcSettingsAction">
*/
public class TmcSettingsAction extends AnAction {
private static final Logger logger = LoggerFactory.getLogger(TmcSettingsAction.class);
private SettingsWindow window;
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
logger.info("Performing TmcSettingsAction. @TmcSettingsAction");
showSettings();
}
public void showSettings() {
logger.info("Opening TMC setting window. @TmcSettingsAction");
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/holders/TmcSettingsManager.java
// public final class TmcSettingsManager {
//
// private static final Logger logger = LoggerFactory.getLogger(TmcSettingsManager.class);
// private static final PersistentTmcSettings persistentSettings =
// ServiceManager.getService(PersistentTmcSettings.class);
//
// private TmcSettingsManager() {}
//
// public static synchronized SettingsTmc get() {
// logger.info("Get SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// return persistentSettings.getSettingsTmc();
// }
//
// public static synchronized void setup() {
// logger.info("Setup SettingsTmc. @TmcSettingsManager.");
// if (persistentSettings.getSettingsTmc() == null) {
// persistentSettings.setSettingsTmc(new SettingsTmc());
// }
// }
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/actions/buttonactions/TmcSettingsAction.java
import fi.helsinki.cs.tmc.intellij.holders.TmcSettingsManager;
import fi.helsinki.cs.tmc.intellij.ui.login.LoginDialog;
import fi.helsinki.cs.tmc.intellij.ui.settings.SettingsWindow;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package fi.helsinki.cs.tmc.intellij.actions.buttonactions;
/**
* Opens the settings window. Defined in plugin.xml on line <action id="Settings"
* class="fi.helsinki.cs.tmc.intellij .actions.buttonactions.TmcSettingsAction">
*/
public class TmcSettingsAction extends AnAction {
private static final Logger logger = LoggerFactory.getLogger(TmcSettingsAction.class);
private SettingsWindow window;
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
logger.info("Performing TmcSettingsAction. @TmcSettingsAction");
showSettings();
}
public void showSettings() {
logger.info("Opening TMC setting window. @TmcSettingsAction");
|
if (TmcSettingsManager.get().getToken().isPresent()) {
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/ExerciseCheckBoxService.java
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/exercisedownloadlist/CustomCheckBoxList.java
// public class CustomCheckBoxList extends JList implements Iterable<JCheckBox> {
//
// private static final Logger logger = LoggerFactory.getLogger(CustomCheckBoxList.class);
// private final List<ItemListener> itemListeners;
//
// public CustomCheckBoxList() {
// logger.info("Creating custom checkbox list");
// this.itemListeners = new ArrayList<>();
// this.setCellRenderer(new CellRenderer());
// this.addMouseListener(
// new MouseAdapter() {
// @Override
// public void mousePressed(MouseEvent event) {
// int index = locationToIndex(event.getPoint());
// if (index != -1) {
// JCheckBox checkbox = (JCheckBox) getModel().getElementAt(index);
// if (CustomCheckBoxList.this.isEnabled() && checkbox.isEnabled()) {
// checkbox.setSelected(!checkbox.isSelected());
// }
// repaint();
// }
// }
// });
// }
//
// private final ItemListener itemEventForwarder =
// this::fireItemEvent;
//
// private final PropertyChangeListener checkBoxPropChangeListener =
// evt -> repaint();
//
// public void addItemListener(ItemListener listener) {
// itemListeners.add(listener);
// }
//
// protected void fireItemEvent(ItemEvent event) {
// for (ItemListener listener : itemListeners) {
// listener.itemStateChanged(event);
// }
// }
//
// public int getElementCount() {
// return getModel().getSize();
// }
//
// public JCheckBox getElement(int element) {
//
// return (JCheckBox) getModel().getElementAt(element);
// }
//
// @NotNull
// @Override
// public Iterator<JCheckBox> iterator() {
// return new Iterator<JCheckBox>() {
// private int iteratori = 0;
//
// @Override
// public boolean hasNext() {
// return iteratori < getElementCount();
// }
//
// @Override
// public JCheckBox next() {
// JCheckBox cb = getElement(iteratori);
// iteratori++;
// return cb;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// };
// }
//
// public void addCheckbox(JCheckBox newCheckBox) {
// newCheckBox.addItemListener(itemEventForwarder);
// newCheckBox.addPropertyChangeListener(checkBoxPropChangeListener);
//
// ListModel model = getModel();
// JCheckBox[] newData = new JCheckBox[model.getSize() + 1];
// for (int i = 0; i < model.getSize(); ++i) {
// newData[i] = (JCheckBox) model.getElementAt(i);
// }
// newData[newData.length - 1] = newCheckBox;
// setListData(newData);
// }
//
// public boolean isSelected(int selecti) {
// return ((JCheckBox) getModel().getElementAt(selecti)).isSelected();
// }
//
// public void setSelected(int setselecti, boolean selected) {
//
// ((JCheckBox) getModel().getElementAt(setselecti)).setSelected(selected);
// }
//
// public boolean isAnySelected() {
// for (int i = 0; i < getModel().getSize(); ++i) {
// if (isSelected(i)) {
// return true;
// }
// }
// return false;
// }
//
// protected class CellRenderer implements ListCellRenderer {
// @Override
// public Component getListCellRendererComponent(
// JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
// JCheckBox checkbox = (JCheckBox) value;
// checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground());
// checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground());
// checkbox.setFont(getFont());
// checkbox.setFocusPainted(false);
// checkbox.setBorderPainted(false);
// checkbox.setBorder(
// isSelected
// ? UIManager.getBorder("List.focusCellHighlightBorder")
// : new EmptyBorder(1, 1, 1, 1));
// return checkbox;
// }
// }
// }
|
import fi.helsinki.cs.tmc.core.domain.Exercise;
import fi.helsinki.cs.tmc.intellij.ui.exercisedownloadlist.CustomCheckBoxList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JCheckBox;
|
package fi.helsinki.cs.tmc.intellij.services;
public class ExerciseCheckBoxService {
private static final Logger logger = LoggerFactory.getLogger(ExerciseCheckBoxService.class);
public static List<Exercise> filterDownloads(
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/exercisedownloadlist/CustomCheckBoxList.java
// public class CustomCheckBoxList extends JList implements Iterable<JCheckBox> {
//
// private static final Logger logger = LoggerFactory.getLogger(CustomCheckBoxList.class);
// private final List<ItemListener> itemListeners;
//
// public CustomCheckBoxList() {
// logger.info("Creating custom checkbox list");
// this.itemListeners = new ArrayList<>();
// this.setCellRenderer(new CellRenderer());
// this.addMouseListener(
// new MouseAdapter() {
// @Override
// public void mousePressed(MouseEvent event) {
// int index = locationToIndex(event.getPoint());
// if (index != -1) {
// JCheckBox checkbox = (JCheckBox) getModel().getElementAt(index);
// if (CustomCheckBoxList.this.isEnabled() && checkbox.isEnabled()) {
// checkbox.setSelected(!checkbox.isSelected());
// }
// repaint();
// }
// }
// });
// }
//
// private final ItemListener itemEventForwarder =
// this::fireItemEvent;
//
// private final PropertyChangeListener checkBoxPropChangeListener =
// evt -> repaint();
//
// public void addItemListener(ItemListener listener) {
// itemListeners.add(listener);
// }
//
// protected void fireItemEvent(ItemEvent event) {
// for (ItemListener listener : itemListeners) {
// listener.itemStateChanged(event);
// }
// }
//
// public int getElementCount() {
// return getModel().getSize();
// }
//
// public JCheckBox getElement(int element) {
//
// return (JCheckBox) getModel().getElementAt(element);
// }
//
// @NotNull
// @Override
// public Iterator<JCheckBox> iterator() {
// return new Iterator<JCheckBox>() {
// private int iteratori = 0;
//
// @Override
// public boolean hasNext() {
// return iteratori < getElementCount();
// }
//
// @Override
// public JCheckBox next() {
// JCheckBox cb = getElement(iteratori);
// iteratori++;
// return cb;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException();
// }
// };
// }
//
// public void addCheckbox(JCheckBox newCheckBox) {
// newCheckBox.addItemListener(itemEventForwarder);
// newCheckBox.addPropertyChangeListener(checkBoxPropChangeListener);
//
// ListModel model = getModel();
// JCheckBox[] newData = new JCheckBox[model.getSize() + 1];
// for (int i = 0; i < model.getSize(); ++i) {
// newData[i] = (JCheckBox) model.getElementAt(i);
// }
// newData[newData.length - 1] = newCheckBox;
// setListData(newData);
// }
//
// public boolean isSelected(int selecti) {
// return ((JCheckBox) getModel().getElementAt(selecti)).isSelected();
// }
//
// public void setSelected(int setselecti, boolean selected) {
//
// ((JCheckBox) getModel().getElementAt(setselecti)).setSelected(selected);
// }
//
// public boolean isAnySelected() {
// for (int i = 0; i < getModel().getSize(); ++i) {
// if (isSelected(i)) {
// return true;
// }
// }
// return false;
// }
//
// protected class CellRenderer implements ListCellRenderer {
// @Override
// public Component getListCellRendererComponent(
// JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
// JCheckBox checkbox = (JCheckBox) value;
// checkbox.setBackground(isSelected ? getSelectionBackground() : getBackground());
// checkbox.setForeground(isSelected ? getSelectionForeground() : getForeground());
// checkbox.setFont(getFont());
// checkbox.setFocusPainted(false);
// checkbox.setBorderPainted(false);
// checkbox.setBorder(
// isSelected
// ? UIManager.getBorder("List.focusCellHighlightBorder")
// : new EmptyBorder(1, 1, 1, 1));
// return checkbox;
// }
// }
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/ExerciseCheckBoxService.java
import fi.helsinki.cs.tmc.core.domain.Exercise;
import fi.helsinki.cs.tmc.intellij.ui.exercisedownloadlist.CustomCheckBoxList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JCheckBox;
package fi.helsinki.cs.tmc.intellij.services;
public class ExerciseCheckBoxService {
private static final Logger logger = LoggerFactory.getLogger(ExerciseCheckBoxService.class);
public static List<Exercise> filterDownloads(
|
CustomCheckBoxList checkBoxes, List<Exercise> exercises) {
|
testmycode/tmc-intellij
|
tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/submissionresult/FailedSubmissionDialog.java
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/testresults/TestResultPanelFactory.java
// public class TestResultPanelFactory implements ToolWindowFactory {
//
// private static final Logger logger = LoggerFactory.getLogger(TestResultPanelFactory.class);
// private static List<TestResultsPanel> panels;
//
// public TestResultPanelFactory() {
// panels = new ArrayList<>();
// }
//
// @Override
// public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
// logger.info("Creating tool window content for test results. " + "@TestResultPanelFactory");
//
// TestResultsPanel panel = new TestResultsPanel();
// ContentFactory cf = ContentFactory.SERVICE.getInstance();
// Content content = cf.createContent(panel, "", true);
// toolWindow.getContentManager().addContent(content);
//
// panels.add(panel);
// }
//
// public static void updateMostRecentResult(List<TestResult> tests, ValidationResult validation) {
// logger.info("Updating the most recent test result. @TestResultPanelFactory.");
// for (TestResultsPanel panel : panels) {
// panel.showResults(tests, validation);
// panel.repaint();
// }
// }
// }
|
import fi.helsinki.cs.tmc.core.domain.submission.SubmissionResult;
import fi.helsinki.cs.tmc.intellij.ui.testresults.TestResultPanelFactory;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
package fi.helsinki.cs.tmc.intellij.ui.submissionresult;
public class FailedSubmissionDialog {
private static final Logger logger = LoggerFactory.getLogger(FailedSubmissionDialog.class);
public FailedSubmissionDialog(SubmissionResult result, Project project) {
logger.info("Showing error message for failed submission. @FailedSubmissionDialog");
String points = parsePoints(result);
String failMessage =
"All tests didn't pass on server!\nSee Test results for more details\n"
+ "Permanent points awarded: "
+ points;
ApplicationManager.getApplication()
.invokeLater(
() -> Messages.showErrorDialog(failMessage, "Some Tests Failed!"));
|
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/testresults/TestResultPanelFactory.java
// public class TestResultPanelFactory implements ToolWindowFactory {
//
// private static final Logger logger = LoggerFactory.getLogger(TestResultPanelFactory.class);
// private static List<TestResultsPanel> panels;
//
// public TestResultPanelFactory() {
// panels = new ArrayList<>();
// }
//
// @Override
// public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
// logger.info("Creating tool window content for test results. " + "@TestResultPanelFactory");
//
// TestResultsPanel panel = new TestResultsPanel();
// ContentFactory cf = ContentFactory.SERVICE.getInstance();
// Content content = cf.createContent(panel, "", true);
// toolWindow.getContentManager().addContent(content);
//
// panels.add(panel);
// }
//
// public static void updateMostRecentResult(List<TestResult> tests, ValidationResult validation) {
// logger.info("Updating the most recent test result. @TestResultPanelFactory.");
// for (TestResultsPanel panel : panels) {
// panel.showResults(tests, validation);
// panel.repaint();
// }
// }
// }
// Path: tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/ui/submissionresult/FailedSubmissionDialog.java
import fi.helsinki.cs.tmc.core.domain.submission.SubmissionResult;
import fi.helsinki.cs.tmc.intellij.ui.testresults.TestResultPanelFactory;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package fi.helsinki.cs.tmc.intellij.ui.submissionresult;
public class FailedSubmissionDialog {
private static final Logger logger = LoggerFactory.getLogger(FailedSubmissionDialog.class);
public FailedSubmissionDialog(SubmissionResult result, Project project) {
logger.info("Showing error message for failed submission. @FailedSubmissionDialog");
String points = parsePoints(result);
String failMessage =
"All tests didn't pass on server!\nSee Test results for more details\n"
+ "Permanent points awarded: "
+ points;
ApplicationManager.getApplication()
.invokeLater(
() -> Messages.showErrorDialog(failMessage, "Some Tests Failed!"));
|
TestResultPanelFactory.updateMostRecentResult(
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/api/furnace/SimpleFurnaceRecipe.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/CraftingIngredient.java
// @FunctionalInterface
// public interface CraftingIngredient extends Predicate<ItemStack>, ConfigurationSerializable {
//
// /**
// * Tests whether an ItemStack matches as an ingredient for the associated crafting recipe.
// *
// * @param itemStack the ItemSack to test
// * @return whether the ItemStack is an ingredient
// */
// public boolean isIngredient(ItemStack itemStack);
//
// /**
// * Convenience method to make CraftingIngredient fit in functions that take a Predicate<ItemStack>.
// * The default implementation delegates to {@link CraftingIngredient#isIngredient}.
// */
// public default boolean test(ItemStack itemStack) {
// return isIngredient(itemStack);
// }
//
// /**
// * Serialize method for ConfigurationSerializable interface.
// * The default implementation returns an empty map.
// */
// public default Map<String, Object> serialize() {
// return Collections.emptyMap();
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/SerializableKey.java
// public class SerializableKey implements ConfigurationSerializable, Keyed {
//
// protected final NamespacedKey key;
//
// public SerializableKey(String namespace, String key) {
// this(new NamespacedKey(namespace, key));
// }
//
// public SerializableKey(NamespacedKey namespacedKey) {
// this.key = Objects.requireNonNull(namespacedKey);
// }
//
// @Override
// public Map<String, Object> serialize() {
// Map<String, Object> map = new HashMap<>();
// map.put("namespace", key.getNamespace());
// map.put("key", key.getKey());
// return map;
// }
//
// public static SerializableKey deserialize(Map<String, Object> map) {
// String namespace = String.valueOf(map.get("namespace"));
// String key = String.valueOf(map.get("key"));
// return new SerializableKey(namespace, key);
// }
//
// @Override
// public NamespacedKey getKey() {
// return key;
// }
//
// }
|
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import com.gmail.jannyboy11.customrecipes.api.crafting.CraftingIngredient;
import com.gmail.jannyboy11.customrecipes.api.SerializableKey;
|
package com.gmail.jannyboy11.customrecipes.api.furnace;
/**
* Represents a simple unregistered furnace recipe POJO.
*
* @author Jan
*/
public final class SimpleFurnaceRecipe implements FurnaceRecipe {
private final NamespacedKey key;
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/CraftingIngredient.java
// @FunctionalInterface
// public interface CraftingIngredient extends Predicate<ItemStack>, ConfigurationSerializable {
//
// /**
// * Tests whether an ItemStack matches as an ingredient for the associated crafting recipe.
// *
// * @param itemStack the ItemSack to test
// * @return whether the ItemStack is an ingredient
// */
// public boolean isIngredient(ItemStack itemStack);
//
// /**
// * Convenience method to make CraftingIngredient fit in functions that take a Predicate<ItemStack>.
// * The default implementation delegates to {@link CraftingIngredient#isIngredient}.
// */
// public default boolean test(ItemStack itemStack) {
// return isIngredient(itemStack);
// }
//
// /**
// * Serialize method for ConfigurationSerializable interface.
// * The default implementation returns an empty map.
// */
// public default Map<String, Object> serialize() {
// return Collections.emptyMap();
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/SerializableKey.java
// public class SerializableKey implements ConfigurationSerializable, Keyed {
//
// protected final NamespacedKey key;
//
// public SerializableKey(String namespace, String key) {
// this(new NamespacedKey(namespace, key));
// }
//
// public SerializableKey(NamespacedKey namespacedKey) {
// this.key = Objects.requireNonNull(namespacedKey);
// }
//
// @Override
// public Map<String, Object> serialize() {
// Map<String, Object> map = new HashMap<>();
// map.put("namespace", key.getNamespace());
// map.put("key", key.getKey());
// return map;
// }
//
// public static SerializableKey deserialize(Map<String, Object> map) {
// String namespace = String.valueOf(map.get("namespace"));
// String key = String.valueOf(map.get("key"));
// return new SerializableKey(namespace, key);
// }
//
// @Override
// public NamespacedKey getKey() {
// return key;
// }
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/furnace/SimpleFurnaceRecipe.java
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import com.gmail.jannyboy11.customrecipes.api.crafting.CraftingIngredient;
import com.gmail.jannyboy11.customrecipes.api.SerializableKey;
package com.gmail.jannyboy11.customrecipes.api.furnace;
/**
* Represents a simple unregistered furnace recipe POJO.
*
* @author Jan
*/
public final class SimpleFurnaceRecipe implements FurnaceRecipe {
private final NamespacedKey key;
|
private CraftingIngredient ingredient;
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/api/furnace/SimpleFurnaceRecipe.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/CraftingIngredient.java
// @FunctionalInterface
// public interface CraftingIngredient extends Predicate<ItemStack>, ConfigurationSerializable {
//
// /**
// * Tests whether an ItemStack matches as an ingredient for the associated crafting recipe.
// *
// * @param itemStack the ItemSack to test
// * @return whether the ItemStack is an ingredient
// */
// public boolean isIngredient(ItemStack itemStack);
//
// /**
// * Convenience method to make CraftingIngredient fit in functions that take a Predicate<ItemStack>.
// * The default implementation delegates to {@link CraftingIngredient#isIngredient}.
// */
// public default boolean test(ItemStack itemStack) {
// return isIngredient(itemStack);
// }
//
// /**
// * Serialize method for ConfigurationSerializable interface.
// * The default implementation returns an empty map.
// */
// public default Map<String, Object> serialize() {
// return Collections.emptyMap();
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/SerializableKey.java
// public class SerializableKey implements ConfigurationSerializable, Keyed {
//
// protected final NamespacedKey key;
//
// public SerializableKey(String namespace, String key) {
// this(new NamespacedKey(namespace, key));
// }
//
// public SerializableKey(NamespacedKey namespacedKey) {
// this.key = Objects.requireNonNull(namespacedKey);
// }
//
// @Override
// public Map<String, Object> serialize() {
// Map<String, Object> map = new HashMap<>();
// map.put("namespace", key.getNamespace());
// map.put("key", key.getKey());
// return map;
// }
//
// public static SerializableKey deserialize(Map<String, Object> map) {
// String namespace = String.valueOf(map.get("namespace"));
// String key = String.valueOf(map.get("key"));
// return new SerializableKey(namespace, key);
// }
//
// @Override
// public NamespacedKey getKey() {
// return key;
// }
//
// }
|
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import com.gmail.jannyboy11.customrecipes.api.crafting.CraftingIngredient;
import com.gmail.jannyboy11.customrecipes.api.SerializableKey;
|
package com.gmail.jannyboy11.customrecipes.api.furnace;
/**
* Represents a simple unregistered furnace recipe POJO.
*
* @author Jan
*/
public final class SimpleFurnaceRecipe implements FurnaceRecipe {
private final NamespacedKey key;
private CraftingIngredient ingredient;
private ItemStack result;
private float xp;
public SimpleFurnaceRecipe(NamespacedKey key, CraftingIngredient ingredient, ItemStack result) {
this.key = Objects.requireNonNull(key, "key cannot be null.");
this.ingredient = Objects.requireNonNull(ingredient, "ingredient cannot be null.");
this.result = Objects.requireNonNull(result, "result cannot be null.");
}
public SimpleFurnaceRecipe(NamespacedKey key, CraftingIngredient ingredient, ItemStack result, float xp) {
this(key, ingredient, result);
this.xp = xp;
}
public SimpleFurnaceRecipe(Map<String, Object> map) {
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/CraftingIngredient.java
// @FunctionalInterface
// public interface CraftingIngredient extends Predicate<ItemStack>, ConfigurationSerializable {
//
// /**
// * Tests whether an ItemStack matches as an ingredient for the associated crafting recipe.
// *
// * @param itemStack the ItemSack to test
// * @return whether the ItemStack is an ingredient
// */
// public boolean isIngredient(ItemStack itemStack);
//
// /**
// * Convenience method to make CraftingIngredient fit in functions that take a Predicate<ItemStack>.
// * The default implementation delegates to {@link CraftingIngredient#isIngredient}.
// */
// public default boolean test(ItemStack itemStack) {
// return isIngredient(itemStack);
// }
//
// /**
// * Serialize method for ConfigurationSerializable interface.
// * The default implementation returns an empty map.
// */
// public default Map<String, Object> serialize() {
// return Collections.emptyMap();
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/SerializableKey.java
// public class SerializableKey implements ConfigurationSerializable, Keyed {
//
// protected final NamespacedKey key;
//
// public SerializableKey(String namespace, String key) {
// this(new NamespacedKey(namespace, key));
// }
//
// public SerializableKey(NamespacedKey namespacedKey) {
// this.key = Objects.requireNonNull(namespacedKey);
// }
//
// @Override
// public Map<String, Object> serialize() {
// Map<String, Object> map = new HashMap<>();
// map.put("namespace", key.getNamespace());
// map.put("key", key.getKey());
// return map;
// }
//
// public static SerializableKey deserialize(Map<String, Object> map) {
// String namespace = String.valueOf(map.get("namespace"));
// String key = String.valueOf(map.get("key"));
// return new SerializableKey(namespace, key);
// }
//
// @Override
// public NamespacedKey getKey() {
// return key;
// }
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/furnace/SimpleFurnaceRecipe.java
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import com.gmail.jannyboy11.customrecipes.api.crafting.CraftingIngredient;
import com.gmail.jannyboy11.customrecipes.api.SerializableKey;
package com.gmail.jannyboy11.customrecipes.api.furnace;
/**
* Represents a simple unregistered furnace recipe POJO.
*
* @author Jan
*/
public final class SimpleFurnaceRecipe implements FurnaceRecipe {
private final NamespacedKey key;
private CraftingIngredient ingredient;
private ItemStack result;
private float xp;
public SimpleFurnaceRecipe(NamespacedKey key, CraftingIngredient ingredient, ItemStack result) {
this.key = Objects.requireNonNull(key, "key cannot be null.");
this.ingredient = Objects.requireNonNull(ingredient, "ingredient cannot be null.");
this.result = Objects.requireNonNull(result, "result cannot be null.");
}
public SimpleFurnaceRecipe(NamespacedKey key, CraftingIngredient ingredient, ItemStack result, float xp) {
this(key, ingredient, result);
this.xp = xp;
}
public SimpleFurnaceRecipe(Map<String, Object> map) {
|
this.key = ((SerializableKey) map.get("key")).getKey();
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/NBTIngredient.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/util/ReflectionUtil.java
// public final class ReflectionUtil {
//
// private ReflectionUtil() {}
//
// public static Field getDeclaredField(Object object, String fieldName) {
// return getDeclaredFieldRecursively(object.getClass(), fieldName);
// }
//
// public static Field getDeclaredFieldRecursively(Class<?> clazz, String fieldName) {
// if (clazz == null) {
// return null;
// }
// try {
// Field field = clazz.getDeclaredField(fieldName);
// field.setAccessible(true);
// return field;
// }
// catch (NoSuchFieldException e) {
// return getDeclaredFieldRecursively(clazz.getSuperclass(), fieldName);
// }
// catch (SecurityException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object getDeclaredFieldValue(Object object, String fieldName) {
// Field field = getDeclaredField(object, fieldName);
// try {
// return field.get(object);
// }
// catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static void setDeclaredFieldValue(Object object, String fieldName, Object value) {
// Field field = getDeclaredField(object, fieldName);
// try {
// field.set(object, value);
// }
// catch (Exception e) {
// e.printStackTrace();
// return;
// }
// }
//
// public static void setFinalFieldValue(Object object, String fieldName, Object value) {
// Field field = getDeclaredField(object, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
//
// field.set(object, value);
// }
// catch (Exception e) {
// e.printStackTrace();
// return;
// }
// }
//
// public static Object getStaticFinalFieldValue(Class<?> clazz, String fieldName) {
// Field field = getDeclaredFieldRecursively(clazz, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// return field.get(null);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static void setStaticFinalFieldValue(Class<?> clazz, String fieldName, Object value) {
// Field field = getDeclaredFieldRecursively(clazz, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// field.set(null, value);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public static Method getDeclaredMethod(Object object, String methodName, Class<?> ... argTypes) {
// return getDeclaredMethodRecursively(object.getClass(), methodName, argTypes);
// }
//
// public static Method getDeclaredMethodRecursively(Class<?> clazz, String methodName, Class<?> ... argTypes) {
// if (clazz == null) {
// return null;
// }
// try {
// Method method = clazz.getDeclaredMethod(methodName, argTypes);
// method.setAccessible(true);
// return method;
// }
// catch (NoSuchMethodException e) {
// return getDeclaredMethodRecursively(clazz.getSuperclass(), methodName, argTypes);
// }
// catch (SecurityException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object invokeInstanceMethod(Object instance, String methodName, Object ... args) {
// Class<?>[] argTypes = new Class[args.length];
// for (int i = 0; i < args.length; i++) {
// argTypes[i] = args[i].getClass();
// }
//
// Method method = getDeclaredMethod(instance, methodName, argTypes);
// try {
// return method.invoke(instance, args);
// }
// catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object invokeStaticMethod(Class<?> clazz, String methodName, Object ... args) {
// Class<?>[] argTypes = new Class[args.length];
// for (int i = 0; i < args.length; i++) {
// argTypes[i] = args[i].getClass();
// }
//
// try {
// Method method = getDeclaredMethodRecursively(clazz, methodName, argTypes);
// return method.invoke(null, args);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// }
|
import java.util.Objects;
import com.gmail.jannyboy11.customrecipes.util.ReflectionUtil;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
|
package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient;
public class NBTIngredient extends CombinedIngredient {
private final RecipeItemStack basePredicate;
public NBTIngredient(RecipeItemStack basePredicate, NBTTagCompound tag) {
super(basePredicate, itemStack -> Objects.equals(itemStack.getTag(), tag), Boolean::logicalAnd);
this.basePredicate = basePredicate;
}
@Override
public RecipeItemStack asNMSIngredient() {
RecipeItemStack recipeItemStack = super.asNMSIngredient();
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/util/ReflectionUtil.java
// public final class ReflectionUtil {
//
// private ReflectionUtil() {}
//
// public static Field getDeclaredField(Object object, String fieldName) {
// return getDeclaredFieldRecursively(object.getClass(), fieldName);
// }
//
// public static Field getDeclaredFieldRecursively(Class<?> clazz, String fieldName) {
// if (clazz == null) {
// return null;
// }
// try {
// Field field = clazz.getDeclaredField(fieldName);
// field.setAccessible(true);
// return field;
// }
// catch (NoSuchFieldException e) {
// return getDeclaredFieldRecursively(clazz.getSuperclass(), fieldName);
// }
// catch (SecurityException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object getDeclaredFieldValue(Object object, String fieldName) {
// Field field = getDeclaredField(object, fieldName);
// try {
// return field.get(object);
// }
// catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static void setDeclaredFieldValue(Object object, String fieldName, Object value) {
// Field field = getDeclaredField(object, fieldName);
// try {
// field.set(object, value);
// }
// catch (Exception e) {
// e.printStackTrace();
// return;
// }
// }
//
// public static void setFinalFieldValue(Object object, String fieldName, Object value) {
// Field field = getDeclaredField(object, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
//
// field.set(object, value);
// }
// catch (Exception e) {
// e.printStackTrace();
// return;
// }
// }
//
// public static Object getStaticFinalFieldValue(Class<?> clazz, String fieldName) {
// Field field = getDeclaredFieldRecursively(clazz, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// return field.get(null);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static void setStaticFinalFieldValue(Class<?> clazz, String fieldName, Object value) {
// Field field = getDeclaredFieldRecursively(clazz, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// field.set(null, value);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public static Method getDeclaredMethod(Object object, String methodName, Class<?> ... argTypes) {
// return getDeclaredMethodRecursively(object.getClass(), methodName, argTypes);
// }
//
// public static Method getDeclaredMethodRecursively(Class<?> clazz, String methodName, Class<?> ... argTypes) {
// if (clazz == null) {
// return null;
// }
// try {
// Method method = clazz.getDeclaredMethod(methodName, argTypes);
// method.setAccessible(true);
// return method;
// }
// catch (NoSuchMethodException e) {
// return getDeclaredMethodRecursively(clazz.getSuperclass(), methodName, argTypes);
// }
// catch (SecurityException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object invokeInstanceMethod(Object instance, String methodName, Object ... args) {
// Class<?>[] argTypes = new Class[args.length];
// for (int i = 0; i < args.length; i++) {
// argTypes[i] = args[i].getClass();
// }
//
// Method method = getDeclaredMethod(instance, methodName, argTypes);
// try {
// return method.invoke(instance, args);
// }
// catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object invokeStaticMethod(Class<?> clazz, String methodName, Object ... args) {
// Class<?>[] argTypes = new Class[args.length];
// for (int i = 0; i < args.length; i++) {
// argTypes[i] = args[i].getClass();
// }
//
// try {
// Method method = getDeclaredMethodRecursively(clazz, methodName, argTypes);
// return method.invoke(null, args);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/NBTIngredient.java
import java.util.Objects;
import com.gmail.jannyboy11.customrecipes.util.ReflectionUtil;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient;
public class NBTIngredient extends CombinedIngredient {
private final RecipeItemStack basePredicate;
public NBTIngredient(RecipeItemStack basePredicate, NBTTagCompound tag) {
super(basePredicate, itemStack -> Objects.equals(itemStack.getTag(), tag), Boolean::logicalAnd);
this.basePredicate = basePredicate;
}
@Override
public RecipeItemStack asNMSIngredient() {
RecipeItemStack recipeItemStack = super.asNMSIngredient();
|
ReflectionUtil.setFinalFieldValue(recipeItemStack, "choices", basePredicate.choices);
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/recipe/NBTRecipe.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/NBTIngredient.java
// public class NBTIngredient extends CombinedIngredient {
//
// private final RecipeItemStack basePredicate;
//
// public NBTIngredient(RecipeItemStack basePredicate, NBTTagCompound tag) {
// super(basePredicate, itemStack -> Objects.equals(itemStack.getTag(), tag), Boolean::logicalAnd);
// this.basePredicate = basePredicate;
// }
//
// @Override
// public RecipeItemStack asNMSIngredient() {
// RecipeItemStack recipeItemStack = super.asNMSIngredient();
// ReflectionUtil.setFinalFieldValue(recipeItemStack, "choices", basePredicate.choices);
// return recipeItemStack;
// }
//
// }
|
import com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient.NBTIngredient;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.NonNullList;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
import net.minecraft.server.v1_12_R1.ShapedRecipes;
|
package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.recipe;
public class NBTRecipe extends ShapedRecipes {
public NBTRecipe(String group, int width, int height, NonNullList<RecipeItemStack> ingredients, ItemStack result) {
super(group, width, height, makeNbtSpecific(ingredients), result);
}
public static NonNullList<RecipeItemStack> makeNbtSpecific(NonNullList<RecipeItemStack> ingredients) {
NonNullList<RecipeItemStack> result = NonNullList.a(ingredients.size(), RecipeItemStack.a);
for (int i = 0; i < ingredients.size(); i++) {
RecipeItemStack ingr = ingredients.get(i);
if (ingr == RecipeItemStack.a) {
result.set(i, RecipeItemStack.a);
continue;
}
ItemStack[] choices = ingr.choices;
if (choices.length == 0) {
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/NBTIngredient.java
// public class NBTIngredient extends CombinedIngredient {
//
// private final RecipeItemStack basePredicate;
//
// public NBTIngredient(RecipeItemStack basePredicate, NBTTagCompound tag) {
// super(basePredicate, itemStack -> Objects.equals(itemStack.getTag(), tag), Boolean::logicalAnd);
// this.basePredicate = basePredicate;
// }
//
// @Override
// public RecipeItemStack asNMSIngredient() {
// RecipeItemStack recipeItemStack = super.asNMSIngredient();
// ReflectionUtil.setFinalFieldValue(recipeItemStack, "choices", basePredicate.choices);
// return recipeItemStack;
// }
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/recipe/NBTRecipe.java
import com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient.NBTIngredient;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.NonNullList;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
import net.minecraft.server.v1_12_R1.ShapedRecipes;
package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.recipe;
public class NBTRecipe extends ShapedRecipes {
public NBTRecipe(String group, int width, int height, NonNullList<RecipeItemStack> ingredients, ItemStack result) {
super(group, width, height, makeNbtSpecific(ingredients), result);
}
public static NonNullList<RecipeItemStack> makeNbtSpecific(NonNullList<RecipeItemStack> ingredients) {
NonNullList<RecipeItemStack> result = NonNullList.a(ingredients.size(), RecipeItemStack.a);
for (int i = 0; i < ingredients.size(); i++) {
RecipeItemStack ingr = ingredients.get(i);
if (ingr == RecipeItemStack.a) {
result.set(i, RecipeItemStack.a);
continue;
}
ItemStack[] choices = ingr.choices;
if (choices.length == 0) {
|
result.set(i, new NBTIngredient(ingr, null).asNMSIngredient());
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/CountIngredient.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/util/ReflectionUtil.java
// public final class ReflectionUtil {
//
// private ReflectionUtil() {}
//
// public static Field getDeclaredField(Object object, String fieldName) {
// return getDeclaredFieldRecursively(object.getClass(), fieldName);
// }
//
// public static Field getDeclaredFieldRecursively(Class<?> clazz, String fieldName) {
// if (clazz == null) {
// return null;
// }
// try {
// Field field = clazz.getDeclaredField(fieldName);
// field.setAccessible(true);
// return field;
// }
// catch (NoSuchFieldException e) {
// return getDeclaredFieldRecursively(clazz.getSuperclass(), fieldName);
// }
// catch (SecurityException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object getDeclaredFieldValue(Object object, String fieldName) {
// Field field = getDeclaredField(object, fieldName);
// try {
// return field.get(object);
// }
// catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static void setDeclaredFieldValue(Object object, String fieldName, Object value) {
// Field field = getDeclaredField(object, fieldName);
// try {
// field.set(object, value);
// }
// catch (Exception e) {
// e.printStackTrace();
// return;
// }
// }
//
// public static void setFinalFieldValue(Object object, String fieldName, Object value) {
// Field field = getDeclaredField(object, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
//
// field.set(object, value);
// }
// catch (Exception e) {
// e.printStackTrace();
// return;
// }
// }
//
// public static Object getStaticFinalFieldValue(Class<?> clazz, String fieldName) {
// Field field = getDeclaredFieldRecursively(clazz, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// return field.get(null);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static void setStaticFinalFieldValue(Class<?> clazz, String fieldName, Object value) {
// Field field = getDeclaredFieldRecursively(clazz, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// field.set(null, value);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public static Method getDeclaredMethod(Object object, String methodName, Class<?> ... argTypes) {
// return getDeclaredMethodRecursively(object.getClass(), methodName, argTypes);
// }
//
// public static Method getDeclaredMethodRecursively(Class<?> clazz, String methodName, Class<?> ... argTypes) {
// if (clazz == null) {
// return null;
// }
// try {
// Method method = clazz.getDeclaredMethod(methodName, argTypes);
// method.setAccessible(true);
// return method;
// }
// catch (NoSuchMethodException e) {
// return getDeclaredMethodRecursively(clazz.getSuperclass(), methodName, argTypes);
// }
// catch (SecurityException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object invokeInstanceMethod(Object instance, String methodName, Object ... args) {
// Class<?>[] argTypes = new Class[args.length];
// for (int i = 0; i < args.length; i++) {
// argTypes[i] = args[i].getClass();
// }
//
// Method method = getDeclaredMethod(instance, methodName, argTypes);
// try {
// return method.invoke(instance, args);
// }
// catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object invokeStaticMethod(Class<?> clazz, String methodName, Object ... args) {
// Class<?>[] argTypes = new Class[args.length];
// for (int i = 0; i < args.length; i++) {
// argTypes[i] = args[i].getClass();
// }
//
// try {
// Method method = getDeclaredMethodRecursively(clazz, methodName, argTypes);
// return method.invoke(null, args);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// }
|
import com.gmail.jannyboy11.customrecipes.util.ReflectionUtil;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
|
package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient;
public class CountIngredient extends CombinedIngredient {
private final RecipeItemStack basePredicate;
private final int count;
public CountIngredient(RecipeItemStack basePredicate, int count) {
super(basePredicate, itemStack -> itemStack.getCount() == count, Boolean::logicalAnd);
this.basePredicate = basePredicate;
this.count = count;
}
@Override
public RecipeItemStack asNMSIngredient() {
RecipeItemStack recipeItemStack = super.asNMSIngredient();
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/util/ReflectionUtil.java
// public final class ReflectionUtil {
//
// private ReflectionUtil() {}
//
// public static Field getDeclaredField(Object object, String fieldName) {
// return getDeclaredFieldRecursively(object.getClass(), fieldName);
// }
//
// public static Field getDeclaredFieldRecursively(Class<?> clazz, String fieldName) {
// if (clazz == null) {
// return null;
// }
// try {
// Field field = clazz.getDeclaredField(fieldName);
// field.setAccessible(true);
// return field;
// }
// catch (NoSuchFieldException e) {
// return getDeclaredFieldRecursively(clazz.getSuperclass(), fieldName);
// }
// catch (SecurityException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object getDeclaredFieldValue(Object object, String fieldName) {
// Field field = getDeclaredField(object, fieldName);
// try {
// return field.get(object);
// }
// catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static void setDeclaredFieldValue(Object object, String fieldName, Object value) {
// Field field = getDeclaredField(object, fieldName);
// try {
// field.set(object, value);
// }
// catch (Exception e) {
// e.printStackTrace();
// return;
// }
// }
//
// public static void setFinalFieldValue(Object object, String fieldName, Object value) {
// Field field = getDeclaredField(object, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
//
// field.set(object, value);
// }
// catch (Exception e) {
// e.printStackTrace();
// return;
// }
// }
//
// public static Object getStaticFinalFieldValue(Class<?> clazz, String fieldName) {
// Field field = getDeclaredFieldRecursively(clazz, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// return field.get(null);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static void setStaticFinalFieldValue(Class<?> clazz, String fieldName, Object value) {
// Field field = getDeclaredFieldRecursively(clazz, fieldName);
// try {
// Field modifiersField = Field.class.getDeclaredField("modifiers");
// modifiersField.setAccessible(true);
// modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
// field.set(null, value);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public static Method getDeclaredMethod(Object object, String methodName, Class<?> ... argTypes) {
// return getDeclaredMethodRecursively(object.getClass(), methodName, argTypes);
// }
//
// public static Method getDeclaredMethodRecursively(Class<?> clazz, String methodName, Class<?> ... argTypes) {
// if (clazz == null) {
// return null;
// }
// try {
// Method method = clazz.getDeclaredMethod(methodName, argTypes);
// method.setAccessible(true);
// return method;
// }
// catch (NoSuchMethodException e) {
// return getDeclaredMethodRecursively(clazz.getSuperclass(), methodName, argTypes);
// }
// catch (SecurityException e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object invokeInstanceMethod(Object instance, String methodName, Object ... args) {
// Class<?>[] argTypes = new Class[args.length];
// for (int i = 0; i < args.length; i++) {
// argTypes[i] = args[i].getClass();
// }
//
// Method method = getDeclaredMethod(instance, methodName, argTypes);
// try {
// return method.invoke(instance, args);
// }
// catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// public static Object invokeStaticMethod(Class<?> clazz, String methodName, Object ... args) {
// Class<?>[] argTypes = new Class[args.length];
// for (int i = 0; i < args.length; i++) {
// argTypes[i] = args[i].getClass();
// }
//
// try {
// Method method = getDeclaredMethodRecursively(clazz, methodName, argTypes);
// return method.invoke(null, args);
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
// }
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/CountIngredient.java
import com.gmail.jannyboy11.customrecipes.util.ReflectionUtil;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient;
public class CountIngredient extends CombinedIngredient {
private final RecipeItemStack basePredicate;
private final int count;
public CountIngredient(RecipeItemStack basePredicate, int count) {
super(basePredicate, itemStack -> itemStack.getCount() == count, Boolean::logicalAnd);
this.basePredicate = basePredicate;
this.count = count;
}
@Override
public RecipeItemStack asNMSIngredient() {
RecipeItemStack recipeItemStack = super.asNMSIngredient();
|
ReflectionUtil.setFinalFieldValue(recipeItemStack, "choices", basePredicate.choices);
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/commands/ListRecipesCommandExecutor.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/gui/ListRecipesInventoryHolder.java
// public class ListRecipesInventoryHolder implements InventoryHolder {
//
// private static final int MAX_RECIPES_PER_PAGE = 9 * 5;
//
// private final List<ItemStack> recipeItems = new ArrayList<>();
// private final List<Inventory> pages = new ArrayList<>();
// private int pageNr = 0;
//
// public ListRecipesInventoryHolder(String type, Iterable<? extends ItemStack> items) {
// items.forEach(recipeItems::add);
//
// //fill page inventories
// int recipeIndex = 0;
// Inventory inventory = null;
// do {
// int inPageIndex = recipeIndex % MAX_RECIPES_PER_PAGE;
// if (inPageIndex == 0) {
// inventory = Bukkit.createInventory(this, 54, type + " recipes");
// pages.add(inventory);
// }
//
// inventory.setItem(inPageIndex, recipeItems.get(recipeIndex));
// } while (++recipeIndex < recipeItems.size());
//
// //add previous and next buttons where applicable
// for (int pageNr = 0; pageNr < pages.size(); pageNr++) {
// Inventory page = pages.get(pageNr);
// if (pageNr != 0) {
// page.setItem(45, ListRecipesListener.previousItem());
// }
// if (pageNr != pages.size() - 1) {
// page.setItem(53, ListRecipesListener.nextItem());
// }
// }
// }
//
// @Override
// public Inventory getInventory() {
// return pages.get(pageNr);
// }
//
// public void nextPage() {
// this.pageNr = Math.min(pageNr + 1, pages.size());
// }
//
// public void previousPage() {
// this.pageNr = Math.max(pageNr - 1, 0);
// }
//
// }
|
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import com.gmail.jannyboy11.customrecipes.gui.ListRecipesInventoryHolder;
|
this.recipeToCommandSenderDiplayMap = recipeToCommandSenderDiplayMap;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) return false;
String recipeType = args[0];
List<? extends Recipe> recipes = recipesByTypeMapper.apply(recipeType);
if (recipes == null) {
sender.sendMessage(ChatColor.RED + "Unknown recipe type: " + recipeType);
return true;
} else if (recipes.isEmpty()) {
sender.sendMessage(ChatColor.RED + "No recipes found for type: " + recipeType);
return true;
}
return sender instanceof Player ? listPlayer((Player) sender, recipeType, recipes) : listSender(sender, recipeType, recipes);
}
private boolean listPlayer(Player player, String recipeType, List<? extends Recipe> recipes) {
Function<? super Recipe, ? extends ItemStack> representationFunction = recipeToItemMap.get(recipeType);
if (representationFunction == null) {
player.sendMessage(ChatColor.RED + "No representation function found for this type of recipe. Trying chat messages..");
return listSender(player, recipeType, recipes);
}
List<? extends ItemStack> representations = recipes.stream().map(representationFunction).collect(Collectors.toList());
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/gui/ListRecipesInventoryHolder.java
// public class ListRecipesInventoryHolder implements InventoryHolder {
//
// private static final int MAX_RECIPES_PER_PAGE = 9 * 5;
//
// private final List<ItemStack> recipeItems = new ArrayList<>();
// private final List<Inventory> pages = new ArrayList<>();
// private int pageNr = 0;
//
// public ListRecipesInventoryHolder(String type, Iterable<? extends ItemStack> items) {
// items.forEach(recipeItems::add);
//
// //fill page inventories
// int recipeIndex = 0;
// Inventory inventory = null;
// do {
// int inPageIndex = recipeIndex % MAX_RECIPES_PER_PAGE;
// if (inPageIndex == 0) {
// inventory = Bukkit.createInventory(this, 54, type + " recipes");
// pages.add(inventory);
// }
//
// inventory.setItem(inPageIndex, recipeItems.get(recipeIndex));
// } while (++recipeIndex < recipeItems.size());
//
// //add previous and next buttons where applicable
// for (int pageNr = 0; pageNr < pages.size(); pageNr++) {
// Inventory page = pages.get(pageNr);
// if (pageNr != 0) {
// page.setItem(45, ListRecipesListener.previousItem());
// }
// if (pageNr != pages.size() - 1) {
// page.setItem(53, ListRecipesListener.nextItem());
// }
// }
// }
//
// @Override
// public Inventory getInventory() {
// return pages.get(pageNr);
// }
//
// public void nextPage() {
// this.pageNr = Math.min(pageNr + 1, pages.size());
// }
//
// public void previousPage() {
// this.pageNr = Math.max(pageNr - 1, 0);
// }
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/commands/ListRecipesCommandExecutor.java
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import com.gmail.jannyboy11.customrecipes.gui.ListRecipesInventoryHolder;
this.recipeToCommandSenderDiplayMap = recipeToCommandSenderDiplayMap;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) return false;
String recipeType = args[0];
List<? extends Recipe> recipes = recipesByTypeMapper.apply(recipeType);
if (recipes == null) {
sender.sendMessage(ChatColor.RED + "Unknown recipe type: " + recipeType);
return true;
} else if (recipes.isEmpty()) {
sender.sendMessage(ChatColor.RED + "No recipes found for type: " + recipeType);
return true;
}
return sender instanceof Player ? listPlayer((Player) sender, recipeType, recipes) : listSender(sender, recipeType, recipes);
}
private boolean listPlayer(Player player, String recipeType, List<? extends Recipe> recipes) {
Function<? super Recipe, ? extends ItemStack> representationFunction = recipeToItemMap.get(recipeType);
if (representationFunction == null) {
player.sendMessage(ChatColor.RED + "No representation function found for this type of recipe. Trying chat messages..");
return listSender(player, recipeType, recipes);
}
List<? extends ItemStack> representations = recipes.stream().map(representationFunction).collect(Collectors.toList());
|
player.openInventory(new ListRecipesInventoryHolder(recipeType, representations).getInventory());
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/impl/furnace/custom/Bukkit2NMSFurnaceRecipe.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/furnace/FurnaceRecipe.java
// public interface FurnaceRecipe extends Recipe, Keyed, ConfigurationSerializable, Representable {
//
// /**
// * Get the ingredient of this furnace recipe.
// *
// * @return the ingredient
// */
// public CraftingIngredient getIngredient();
//
// /**
// * Get the output of this furnace recipe.
// *
// * @return the output
// */
// public ItemStack getResult();
//
// /**
// * Get the experience that is granted for using this furnace recipe.
// *
// * @return the experienced
// */
// public float getXp();
//
// /**
// * Set the ingredient of this furnace recipe.
// *
// * @param ingredient
// */
// public void setIngredient(CraftingIngredient ingredient);
//
// /**
// * Set the output of this furnace recipe.
// *
// * @param result the output
// */
// public void setResult(ItemStack result);
//
// /**
// * Set the experience of this furnace recipe.
// *
// * @param xp the experience
// */
// public void setXp(float xp);
//
// /**
// * Gets the representation. The default implementation returns the result ItemStack.
// *
// * @return the representation - same as {@link FurnaceRecipe#getResult()}
// */
// public default ItemStack getRepresentation() {
// return getResult();
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/CRCraftingIngredient.java
// public class CRCraftingIngredient<I extends RecipeItemStack> implements CraftingIngredient, NBTSerializable {
//
// protected final I nmsIngredient;
//
// public CRCraftingIngredient(I nmsIngredient) {
// this.nmsIngredient = nmsIngredient;
// }
//
// @Override
// public boolean isIngredient(ItemStack itemStack) {
// return this.nmsIngredient.a(CraftItemStack.asNMSCopy(itemStack));
// }
//
// @Override
// public NBTTagCompound serializeToNbt() {
// return NBTUtil.serializeRecipeItemStack(nmsIngredient);
// }
//
// @Override
// public Map<String, Object> serialize() {
// return NBTSerializable.super.serialize();
// }
//
// public static CRChoiceIngredient asBukkitIngredient(RecipeItemStack ingredient) {
// //TODO can we handle subclasses of RecipeItemStack?
// return ingredient == RecipeItemStack.a ? CREmptyIngredient.INSTANCE : new CRChoiceIngredient(ingredient);
// }
//
// public static RecipeItemStack asNMSIngredient(ChoiceIngredient ingredient) {
// if (ingredient instanceof CRChoiceIngredient) {
// CRChoiceIngredient crIngredient = (CRChoiceIngredient) ingredient;
// return crIngredient.nmsIngredient;
// }
//
// RecipeItemStack nmsIngredient = asNMSIngredient((CraftingIngredient) ingredient);
// ItemStack[] choices = ingredient.getChoices().stream().map(CraftItemStack::asNMSCopy).toArray(size -> new ItemStack[size]);
// ReflectionUtil.setFinalFieldValue(nmsIngredient, "choices", choices);
//
// return nmsIngredient;
// }
//
// public static RecipeItemStack asNMSIngredient(CraftingIngredient ingredient) {
// if (ingredient instanceof CRCraftingIngredient) {
// @SuppressWarnings("unchecked")
// CRCraftingIngredient<RecipeItemStack> crIngredient = (CRCraftingIngredient<RecipeItemStack>) ingredient;
// return crIngredient.nmsIngredient;
// }
//
// //fallback
// return new Bukkit2NMSIngredient(ingredient).asNMSIngredient();
// }
//
// }
|
import java.util.Objects;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_12_R1.util.CraftNamespacedKey;
import com.gmail.jannyboy11.customrecipes.api.furnace.FurnaceRecipe;
import com.gmail.jannyboy11.customrecipes.impl.crafting.CRCraftingIngredient;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.MinecraftKey;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
|
package com.gmail.jannyboy11.customrecipes.impl.furnace.custom;
public class Bukkit2NMSFurnaceRecipe extends NMSFurnaceRecipe {
public Bukkit2NMSFurnaceRecipe(FurnaceRecipe bukkit) {
this.bukkit = Objects.requireNonNull(bukkit);
}
@Override
public MinecraftKey getKey() {
return CraftNamespacedKey.toMinecraft(bukkit.getKey());
}
@Override
public RecipeItemStack getIngredient() {
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/furnace/FurnaceRecipe.java
// public interface FurnaceRecipe extends Recipe, Keyed, ConfigurationSerializable, Representable {
//
// /**
// * Get the ingredient of this furnace recipe.
// *
// * @return the ingredient
// */
// public CraftingIngredient getIngredient();
//
// /**
// * Get the output of this furnace recipe.
// *
// * @return the output
// */
// public ItemStack getResult();
//
// /**
// * Get the experience that is granted for using this furnace recipe.
// *
// * @return the experienced
// */
// public float getXp();
//
// /**
// * Set the ingredient of this furnace recipe.
// *
// * @param ingredient
// */
// public void setIngredient(CraftingIngredient ingredient);
//
// /**
// * Set the output of this furnace recipe.
// *
// * @param result the output
// */
// public void setResult(ItemStack result);
//
// /**
// * Set the experience of this furnace recipe.
// *
// * @param xp the experience
// */
// public void setXp(float xp);
//
// /**
// * Gets the representation. The default implementation returns the result ItemStack.
// *
// * @return the representation - same as {@link FurnaceRecipe#getResult()}
// */
// public default ItemStack getRepresentation() {
// return getResult();
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/CRCraftingIngredient.java
// public class CRCraftingIngredient<I extends RecipeItemStack> implements CraftingIngredient, NBTSerializable {
//
// protected final I nmsIngredient;
//
// public CRCraftingIngredient(I nmsIngredient) {
// this.nmsIngredient = nmsIngredient;
// }
//
// @Override
// public boolean isIngredient(ItemStack itemStack) {
// return this.nmsIngredient.a(CraftItemStack.asNMSCopy(itemStack));
// }
//
// @Override
// public NBTTagCompound serializeToNbt() {
// return NBTUtil.serializeRecipeItemStack(nmsIngredient);
// }
//
// @Override
// public Map<String, Object> serialize() {
// return NBTSerializable.super.serialize();
// }
//
// public static CRChoiceIngredient asBukkitIngredient(RecipeItemStack ingredient) {
// //TODO can we handle subclasses of RecipeItemStack?
// return ingredient == RecipeItemStack.a ? CREmptyIngredient.INSTANCE : new CRChoiceIngredient(ingredient);
// }
//
// public static RecipeItemStack asNMSIngredient(ChoiceIngredient ingredient) {
// if (ingredient instanceof CRChoiceIngredient) {
// CRChoiceIngredient crIngredient = (CRChoiceIngredient) ingredient;
// return crIngredient.nmsIngredient;
// }
//
// RecipeItemStack nmsIngredient = asNMSIngredient((CraftingIngredient) ingredient);
// ItemStack[] choices = ingredient.getChoices().stream().map(CraftItemStack::asNMSCopy).toArray(size -> new ItemStack[size]);
// ReflectionUtil.setFinalFieldValue(nmsIngredient, "choices", choices);
//
// return nmsIngredient;
// }
//
// public static RecipeItemStack asNMSIngredient(CraftingIngredient ingredient) {
// if (ingredient instanceof CRCraftingIngredient) {
// @SuppressWarnings("unchecked")
// CRCraftingIngredient<RecipeItemStack> crIngredient = (CRCraftingIngredient<RecipeItemStack>) ingredient;
// return crIngredient.nmsIngredient;
// }
//
// //fallback
// return new Bukkit2NMSIngredient(ingredient).asNMSIngredient();
// }
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/furnace/custom/Bukkit2NMSFurnaceRecipe.java
import java.util.Objects;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_12_R1.util.CraftNamespacedKey;
import com.gmail.jannyboy11.customrecipes.api.furnace.FurnaceRecipe;
import com.gmail.jannyboy11.customrecipes.impl.crafting.CRCraftingIngredient;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.MinecraftKey;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
package com.gmail.jannyboy11.customrecipes.impl.furnace.custom;
public class Bukkit2NMSFurnaceRecipe extends NMSFurnaceRecipe {
public Bukkit2NMSFurnaceRecipe(FurnaceRecipe bukkit) {
this.bukkit = Objects.requireNonNull(bukkit);
}
@Override
public MinecraftKey getKey() {
return CraftNamespacedKey.toMinecraft(bukkit.getKey());
}
@Override
public RecipeItemStack getIngredient() {
|
return CRCraftingIngredient.asNMSIngredient(bukkit.getIngredient());
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/SimpleCraftingRecipe.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/InventoryUtils.java
// public final class InventoryUtils {
//
// private InventoryUtils() {}
//
// /**
// * Checks whether the given ItemStack is empty.
// *
// * @return true when the given ItemStack is empty, otherwise false
// */
// public static boolean isEmptyStack(ItemStack itemStack) {
// return itemStack == null || itemStack.getType() == Material.AIR || itemStack.getAmount() < 1;
// }
//
// /**
// * Get the name of an ItemStack
// *
// * @param itemStack the itemStack
// * @return the name if present, otherwise the name of the Material
// */
// public static String getItemName(ItemStack itemStack) {
// if (itemStack == null) return Material.AIR.name();
//
// if (itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName()) {
// return itemStack.getItemMeta().getDisplayName();
// }
//
// return itemStack.getType().name();
// }
//
// /**
// * Get 2d coordinates of an inventory slot.
// *
// * @param rowLength the length of rows in the inventory
// * @param index the slot number
// * @return an array of two ints, the first being the row number, the second being the column number
// */
// public static int[] inventoryRownumColnum(int rowLength, int index) {
// int rowNum = index / rowLength;
// int colNum = index - rowNum * rowLength;
// return new int[]{rowNum, colNum};
// }
//
// /**
// * Get the inventory slot number from 2d coordinates.
// *
// * @param rowLength the length of rows in the inventory
// * @param rownumColnum an array of length 2, the first int being the row number, the second int being the column number
// * @return the slot number
// */
// public static int inventoryIndex(int rowLength, int[] rownumColnum) {
// int rowNum = rownumColnum[0];
// int colNum = rownumColnum[1];
// return rowNum * rowLength + colNum;
// }
//
// /**
// * Checks whether the inventory is empty
// *
// * @param inventory the inventory
// * @return true if the inventory is empty, otherwise false
// */
// public static boolean isEmpty(Inventory inventory) {
// return StreamSupport.stream(Spliterators.spliterator(inventory.iterator(),
// inventory.getSize(), Spliterator.SIZED), false)
// .allMatch(InventoryUtils::isEmptyStack);
// }
//
// /**
// * Get the MaterialData that vanilla crafting recipes leave in a crafting inventory if the ingredient is of stack size 1.
// * For most materials the returned data will have Material.AIR, but there are exceptions for filled buckets and dragons breath.
// *
// * @param ingredient the material data used as a crafting ingredient.
// * @return the material data that vanilla recipes would give back upon crafting
// */
// public static MaterialData getSingleIngredientResult(MaterialData ingredient) {
// if (ingredient == null) return new MaterialData(Material.AIR);
//
// switch(ingredient.getItemType()) {
// case MILK_BUCKET:
// case WATER_BUCKET:
// case LAVA_BUCKET:
// return new MaterialData(Material.BUCKET);
//
// case DRAGONS_BREATH:
// return new MaterialData(Material.GLASS_BOTTLE);
//
// default: return new MaterialData(Material.AIR);
// }
// }
//
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.jannyboy11.customrecipes.api.InventoryUtils;
|
return result;
}
/**
* Set the result of this recipe
* @param result the result
*/
public void setResult(ItemStack result) {
this.result = result;
}
/**
* {@inheritDoc}
*/
@Override
public ItemStack craftItem(CraftingInventory craftingInventory) {
return result == null ? null : result.clone();
}
/**
* {@inheritDoc}
*/
@Override
public List<? extends ItemStack> getLeftOverItems(CraftingInventory craftingInventory) {
ItemStack[] matrix = craftingInventory.getMatrix();
List<ItemStack> leftOver = new ArrayList<>(matrix.length);
for (int i = 0; i < matrix.length; i++) {
ItemStack itemStack = matrix[i];
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/InventoryUtils.java
// public final class InventoryUtils {
//
// private InventoryUtils() {}
//
// /**
// * Checks whether the given ItemStack is empty.
// *
// * @return true when the given ItemStack is empty, otherwise false
// */
// public static boolean isEmptyStack(ItemStack itemStack) {
// return itemStack == null || itemStack.getType() == Material.AIR || itemStack.getAmount() < 1;
// }
//
// /**
// * Get the name of an ItemStack
// *
// * @param itemStack the itemStack
// * @return the name if present, otherwise the name of the Material
// */
// public static String getItemName(ItemStack itemStack) {
// if (itemStack == null) return Material.AIR.name();
//
// if (itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName()) {
// return itemStack.getItemMeta().getDisplayName();
// }
//
// return itemStack.getType().name();
// }
//
// /**
// * Get 2d coordinates of an inventory slot.
// *
// * @param rowLength the length of rows in the inventory
// * @param index the slot number
// * @return an array of two ints, the first being the row number, the second being the column number
// */
// public static int[] inventoryRownumColnum(int rowLength, int index) {
// int rowNum = index / rowLength;
// int colNum = index - rowNum * rowLength;
// return new int[]{rowNum, colNum};
// }
//
// /**
// * Get the inventory slot number from 2d coordinates.
// *
// * @param rowLength the length of rows in the inventory
// * @param rownumColnum an array of length 2, the first int being the row number, the second int being the column number
// * @return the slot number
// */
// public static int inventoryIndex(int rowLength, int[] rownumColnum) {
// int rowNum = rownumColnum[0];
// int colNum = rownumColnum[1];
// return rowNum * rowLength + colNum;
// }
//
// /**
// * Checks whether the inventory is empty
// *
// * @param inventory the inventory
// * @return true if the inventory is empty, otherwise false
// */
// public static boolean isEmpty(Inventory inventory) {
// return StreamSupport.stream(Spliterators.spliterator(inventory.iterator(),
// inventory.getSize(), Spliterator.SIZED), false)
// .allMatch(InventoryUtils::isEmptyStack);
// }
//
// /**
// * Get the MaterialData that vanilla crafting recipes leave in a crafting inventory if the ingredient is of stack size 1.
// * For most materials the returned data will have Material.AIR, but there are exceptions for filled buckets and dragons breath.
// *
// * @param ingredient the material data used as a crafting ingredient.
// * @return the material data that vanilla recipes would give back upon crafting
// */
// public static MaterialData getSingleIngredientResult(MaterialData ingredient) {
// if (ingredient == null) return new MaterialData(Material.AIR);
//
// switch(ingredient.getItemType()) {
// case MILK_BUCKET:
// case WATER_BUCKET:
// case LAVA_BUCKET:
// return new MaterialData(Material.BUCKET);
//
// case DRAGONS_BREATH:
// return new MaterialData(Material.GLASS_BOTTLE);
//
// default: return new MaterialData(Material.AIR);
// }
// }
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/SimpleCraftingRecipe.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.jannyboy11.customrecipes.api.InventoryUtils;
return result;
}
/**
* Set the result of this recipe
* @param result the result
*/
public void setResult(ItemStack result) {
this.result = result;
}
/**
* {@inheritDoc}
*/
@Override
public ItemStack craftItem(CraftingInventory craftingInventory) {
return result == null ? null : result.clone();
}
/**
* {@inheritDoc}
*/
@Override
public List<? extends ItemStack> getLeftOverItems(CraftingInventory craftingInventory) {
ItemStack[] matrix = craftingInventory.getMatrix();
List<ItemStack> leftOver = new ArrayList<>(matrix.length);
for (int i = 0; i < matrix.length; i++) {
ItemStack itemStack = matrix[i];
|
if (InventoryUtils.isEmptyStack(itemStack)) {
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/recipe/CountRecipe.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/CountIngredient.java
// public class CountIngredient extends CombinedIngredient {
//
// private final RecipeItemStack basePredicate;
// private final int count;
//
// public CountIngredient(RecipeItemStack basePredicate, int count) {
// super(basePredicate, itemStack -> itemStack.getCount() == count, Boolean::logicalAnd);
// this.basePredicate = basePredicate;
// this.count = count;
// }
//
// @Override
// public RecipeItemStack asNMSIngredient() {
// RecipeItemStack recipeItemStack = super.asNMSIngredient();
// ReflectionUtil.setFinalFieldValue(recipeItemStack, "choices", basePredicate.choices);
// return recipeItemStack;
// }
//
// public int getCount() {
// return count;
// }
//
// }
|
import com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient.CountIngredient;
import net.minecraft.server.v1_12_R1.InventoryCrafting;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.NonNullList;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
import net.minecraft.server.v1_12_R1.ShapedRecipes;
|
package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.recipe;
public class CountRecipe extends ShapedRecipes {
public CountRecipe(String group, int width, int heigth, NonNullList<RecipeItemStack> ingredients, ItemStack result) {
super(group, width, heigth, makeCountSpecific(ingredients), result);
}
public static NonNullList<RecipeItemStack> makeCountSpecific(NonNullList<RecipeItemStack> ingredients) {
NonNullList<RecipeItemStack> result = NonNullList.a(ingredients.size(), RecipeItemStack.a);
for (int i = 0; i < ingredients.size(); i++) {
RecipeItemStack ingr = ingredients.get(i);
if (ingr == RecipeItemStack.a) {
result.set(i, RecipeItemStack.a);
continue;
}
ItemStack[] choices = ingr.choices;
if (choices.length == 0) {
continue;
}
ItemStack firstChoice = choices[0];
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/ingredient/CountIngredient.java
// public class CountIngredient extends CombinedIngredient {
//
// private final RecipeItemStack basePredicate;
// private final int count;
//
// public CountIngredient(RecipeItemStack basePredicate, int count) {
// super(basePredicate, itemStack -> itemStack.getCount() == count, Boolean::logicalAnd);
// this.basePredicate = basePredicate;
// this.count = count;
// }
//
// @Override
// public RecipeItemStack asNMSIngredient() {
// RecipeItemStack recipeItemStack = super.asNMSIngredient();
// ReflectionUtil.setFinalFieldValue(recipeItemStack, "choices", basePredicate.choices);
// return recipeItemStack;
// }
//
// public int getCount() {
// return count;
// }
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/impl/crafting/custom/recipe/CountRecipe.java
import com.gmail.jannyboy11.customrecipes.impl.crafting.custom.ingredient.CountIngredient;
import net.minecraft.server.v1_12_R1.InventoryCrafting;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.NonNullList;
import net.minecraft.server.v1_12_R1.RecipeItemStack;
import net.minecraft.server.v1_12_R1.ShapedRecipes;
package com.gmail.jannyboy11.customrecipes.impl.crafting.custom.recipe;
public class CountRecipe extends ShapedRecipes {
public CountRecipe(String group, int width, int heigth, NonNullList<RecipeItemStack> ingredients, ItemStack result) {
super(group, width, heigth, makeCountSpecific(ingredients), result);
}
public static NonNullList<RecipeItemStack> makeCountSpecific(NonNullList<RecipeItemStack> ingredients) {
NonNullList<RecipeItemStack> result = NonNullList.a(ingredients.size(), RecipeItemStack.a);
for (int i = 0; i < ingredients.size(); i++) {
RecipeItemStack ingr = ingredients.get(i);
if (ingr == RecipeItemStack.a) {
result.set(i, RecipeItemStack.a);
continue;
}
ItemStack[] choices = ingr.choices;
if (choices.length == 0) {
continue;
}
ItemStack firstChoice = choices[0];
|
result.set(i, new CountIngredient(ingr, firstChoice.getCount()).asNMSIngredient());
|
Jannyboy11/CustomRecipes
|
src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/SimpleChoiceIngredient.java
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/InventoryUtils.java
// public final class InventoryUtils {
//
// private InventoryUtils() {}
//
// /**
// * Checks whether the given ItemStack is empty.
// *
// * @return true when the given ItemStack is empty, otherwise false
// */
// public static boolean isEmptyStack(ItemStack itemStack) {
// return itemStack == null || itemStack.getType() == Material.AIR || itemStack.getAmount() < 1;
// }
//
// /**
// * Get the name of an ItemStack
// *
// * @param itemStack the itemStack
// * @return the name if present, otherwise the name of the Material
// */
// public static String getItemName(ItemStack itemStack) {
// if (itemStack == null) return Material.AIR.name();
//
// if (itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName()) {
// return itemStack.getItemMeta().getDisplayName();
// }
//
// return itemStack.getType().name();
// }
//
// /**
// * Get 2d coordinates of an inventory slot.
// *
// * @param rowLength the length of rows in the inventory
// * @param index the slot number
// * @return an array of two ints, the first being the row number, the second being the column number
// */
// public static int[] inventoryRownumColnum(int rowLength, int index) {
// int rowNum = index / rowLength;
// int colNum = index - rowNum * rowLength;
// return new int[]{rowNum, colNum};
// }
//
// /**
// * Get the inventory slot number from 2d coordinates.
// *
// * @param rowLength the length of rows in the inventory
// * @param rownumColnum an array of length 2, the first int being the row number, the second int being the column number
// * @return the slot number
// */
// public static int inventoryIndex(int rowLength, int[] rownumColnum) {
// int rowNum = rownumColnum[0];
// int colNum = rownumColnum[1];
// return rowNum * rowLength + colNum;
// }
//
// /**
// * Checks whether the inventory is empty
// *
// * @param inventory the inventory
// * @return true if the inventory is empty, otherwise false
// */
// public static boolean isEmpty(Inventory inventory) {
// return StreamSupport.stream(Spliterators.spliterator(inventory.iterator(),
// inventory.getSize(), Spliterator.SIZED), false)
// .allMatch(InventoryUtils::isEmptyStack);
// }
//
// /**
// * Get the MaterialData that vanilla crafting recipes leave in a crafting inventory if the ingredient is of stack size 1.
// * For most materials the returned data will have Material.AIR, but there are exceptions for filled buckets and dragons breath.
// *
// * @param ingredient the material data used as a crafting ingredient.
// * @return the material data that vanilla recipes would give back upon crafting
// */
// public static MaterialData getSingleIngredientResult(MaterialData ingredient) {
// if (ingredient == null) return new MaterialData(Material.AIR);
//
// switch(ingredient.getItemType()) {
// case MILK_BUCKET:
// case WATER_BUCKET:
// case LAVA_BUCKET:
// return new MaterialData(Material.BUCKET);
//
// case DRAGONS_BREATH:
// return new MaterialData(Material.GLASS_BOTTLE);
//
// default: return new MaterialData(Material.AIR);
// }
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/vanilla/ingredient/ChoiceIngredient.java
// public interface ChoiceIngredient extends CraftingIngredient {
//
// /**
// * Get the list of choices.
// * @return the list of choices
// */
// public List<? extends ItemStack> getChoices();
//
//
// /**
// * Serialize method for ConfigurationSerializable interface.
// * The default implementation returns a singleton map, the key is "choices" and the value is the list of ItemStacks.
// */
// public default Map<String, Object> serialize() {
// return Collections.singletonMap("choices", getChoices());
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/vanilla/ingredient/EmptyIngredient.java
// public interface EmptyIngredient extends ChoiceIngredient {
//
// }
|
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import com.gmail.jannyboy11.customrecipes.api.InventoryUtils;
import com.gmail.jannyboy11.customrecipes.api.crafting.vanilla.ingredient.ChoiceIngredient;
import com.gmail.jannyboy11.customrecipes.api.crafting.vanilla.ingredient.EmptyIngredient;
|
package com.gmail.jannyboy11.customrecipes.api.crafting;
/**
* Represents an ingredient for crafting recipes that aims to mirror vanilla ingredients.
*
* @author Jan
*/
public class SimpleChoiceIngredient implements ChoiceIngredient {
private static class SimpleEmptyIngredient extends SimpleChoiceIngredient implements EmptyIngredient {
private SimpleEmptyIngredient() {
super(Collections.emptyList());
}
/**
* Check if the ItemStack is accepted by this ingredient.
* @return true if the itemStack is null or air, otherwise false
*/
@Override
public boolean isIngredient(ItemStack itemStack) {
|
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/InventoryUtils.java
// public final class InventoryUtils {
//
// private InventoryUtils() {}
//
// /**
// * Checks whether the given ItemStack is empty.
// *
// * @return true when the given ItemStack is empty, otherwise false
// */
// public static boolean isEmptyStack(ItemStack itemStack) {
// return itemStack == null || itemStack.getType() == Material.AIR || itemStack.getAmount() < 1;
// }
//
// /**
// * Get the name of an ItemStack
// *
// * @param itemStack the itemStack
// * @return the name if present, otherwise the name of the Material
// */
// public static String getItemName(ItemStack itemStack) {
// if (itemStack == null) return Material.AIR.name();
//
// if (itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName()) {
// return itemStack.getItemMeta().getDisplayName();
// }
//
// return itemStack.getType().name();
// }
//
// /**
// * Get 2d coordinates of an inventory slot.
// *
// * @param rowLength the length of rows in the inventory
// * @param index the slot number
// * @return an array of two ints, the first being the row number, the second being the column number
// */
// public static int[] inventoryRownumColnum(int rowLength, int index) {
// int rowNum = index / rowLength;
// int colNum = index - rowNum * rowLength;
// return new int[]{rowNum, colNum};
// }
//
// /**
// * Get the inventory slot number from 2d coordinates.
// *
// * @param rowLength the length of rows in the inventory
// * @param rownumColnum an array of length 2, the first int being the row number, the second int being the column number
// * @return the slot number
// */
// public static int inventoryIndex(int rowLength, int[] rownumColnum) {
// int rowNum = rownumColnum[0];
// int colNum = rownumColnum[1];
// return rowNum * rowLength + colNum;
// }
//
// /**
// * Checks whether the inventory is empty
// *
// * @param inventory the inventory
// * @return true if the inventory is empty, otherwise false
// */
// public static boolean isEmpty(Inventory inventory) {
// return StreamSupport.stream(Spliterators.spliterator(inventory.iterator(),
// inventory.getSize(), Spliterator.SIZED), false)
// .allMatch(InventoryUtils::isEmptyStack);
// }
//
// /**
// * Get the MaterialData that vanilla crafting recipes leave in a crafting inventory if the ingredient is of stack size 1.
// * For most materials the returned data will have Material.AIR, but there are exceptions for filled buckets and dragons breath.
// *
// * @param ingredient the material data used as a crafting ingredient.
// * @return the material data that vanilla recipes would give back upon crafting
// */
// public static MaterialData getSingleIngredientResult(MaterialData ingredient) {
// if (ingredient == null) return new MaterialData(Material.AIR);
//
// switch(ingredient.getItemType()) {
// case MILK_BUCKET:
// case WATER_BUCKET:
// case LAVA_BUCKET:
// return new MaterialData(Material.BUCKET);
//
// case DRAGONS_BREATH:
// return new MaterialData(Material.GLASS_BOTTLE);
//
// default: return new MaterialData(Material.AIR);
// }
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/vanilla/ingredient/ChoiceIngredient.java
// public interface ChoiceIngredient extends CraftingIngredient {
//
// /**
// * Get the list of choices.
// * @return the list of choices
// */
// public List<? extends ItemStack> getChoices();
//
//
// /**
// * Serialize method for ConfigurationSerializable interface.
// * The default implementation returns a singleton map, the key is "choices" and the value is the list of ItemStacks.
// */
// public default Map<String, Object> serialize() {
// return Collections.singletonMap("choices", getChoices());
// }
//
// }
//
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/vanilla/ingredient/EmptyIngredient.java
// public interface EmptyIngredient extends ChoiceIngredient {
//
// }
// Path: src/main/java/com/gmail/jannyboy11/customrecipes/api/crafting/SimpleChoiceIngredient.java
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import com.gmail.jannyboy11.customrecipes.api.InventoryUtils;
import com.gmail.jannyboy11.customrecipes.api.crafting.vanilla.ingredient.ChoiceIngredient;
import com.gmail.jannyboy11.customrecipes.api.crafting.vanilla.ingredient.EmptyIngredient;
package com.gmail.jannyboy11.customrecipes.api.crafting;
/**
* Represents an ingredient for crafting recipes that aims to mirror vanilla ingredients.
*
* @author Jan
*/
public class SimpleChoiceIngredient implements ChoiceIngredient {
private static class SimpleEmptyIngredient extends SimpleChoiceIngredient implements EmptyIngredient {
private SimpleEmptyIngredient() {
super(Collections.emptyList());
}
/**
* Check if the ItemStack is accepted by this ingredient.
* @return true if the itemStack is null or air, otherwise false
*/
@Override
public boolean isIngredient(ItemStack itemStack) {
|
return InventoryUtils.isEmptyStack(itemStack);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCHoe.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemHoe;
|
package cn.mccraft.chinacraft.item;
public class ItemCCHoe extends ItemHoe{
public ItemCCHoe(ToolMaterial material) {
super(material);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCHoe.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemHoe;
package cn.mccraft.chinacraft.item;
public class ItemCCHoe extends ItemHoe{
public ItemCCHoe(ToolMaterial material) {
super(material);
|
setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/api/recipe/CrusherRecipe.java
|
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/EnumCrusherMaterial.java
// public enum EnumCrusherMaterial implements IStringSerializable {
// // Grey
// STONE(189, 189, 189, 1),
//
// // Deep orange
// BRONZE(255, 171, 145, 1),
//
// // Grey lighten
// IRON(245, 245, 245, 1);
//
// private float r, g, b, a;
//
// EnumCrusherMaterial(int r, int g, int b, int a) {
// Color color = new Color(r, g, b, a);
// this.r = color.getRGBComponents(null)[0];
// this.g = color.getRGBComponents(null)[1];
// this.b = color.getRGBComponents(null)[2];
// this.a = color.getRGBComponents(null)[3];
// }
//
// public float getRed() {
// return r;
// }
//
// public float getGreen() {
// return g;
// }
//
// public float getBlue() {
// return b;
// }
//
// public float getAlpha() {
// return a;
// }
//
// @Override
// public String getName() {
// return this.toString().toLowerCase();
// }
// }
|
import cn.mccraft.chinacraft.block.machine.EnumCrusherMaterial;
|
package cn.mccraft.chinacraft.api.recipe;
public class CrusherRecipe extends SimpleOreRecipe {
private int time;
private int energy;
|
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/EnumCrusherMaterial.java
// public enum EnumCrusherMaterial implements IStringSerializable {
// // Grey
// STONE(189, 189, 189, 1),
//
// // Deep orange
// BRONZE(255, 171, 145, 1),
//
// // Grey lighten
// IRON(245, 245, 245, 1);
//
// private float r, g, b, a;
//
// EnumCrusherMaterial(int r, int g, int b, int a) {
// Color color = new Color(r, g, b, a);
// this.r = color.getRGBComponents(null)[0];
// this.g = color.getRGBComponents(null)[1];
// this.b = color.getRGBComponents(null)[2];
// this.a = color.getRGBComponents(null)[3];
// }
//
// public float getRed() {
// return r;
// }
//
// public float getGreen() {
// return g;
// }
//
// public float getBlue() {
// return b;
// }
//
// public float getAlpha() {
// return a;
// }
//
// @Override
// public String getName() {
// return this.toString().toLowerCase();
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/api/recipe/CrusherRecipe.java
import cn.mccraft.chinacraft.block.machine.EnumCrusherMaterial;
package cn.mccraft.chinacraft.api.recipe;
public class CrusherRecipe extends SimpleOreRecipe {
private int time;
private int energy;
|
private EnumCrusherMaterial material = EnumCrusherMaterial.STONE;
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/inventory/ContainerRedPacket.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCItems.java
// public interface CCItems {
// Item.ToolMaterial BRONZE_TOOL_MATERIAL = EnumHelper.addToolMaterial("BRONZE", 2, 232, 5.0F, 1.75F, 9);
//
// @RegItem(value = {"copper", "ingot"}, oreDict = {"ingotCopper"})
// ItemCCBase COPPER_INGOT = new ItemCCBase();
//
// @RegItem(value = {"tin", "ingot"}, oreDict = {"ingotTin"})
// ItemCCBase TIN_INGOT = new ItemCCBase();
//
// @RegItem(value = {"bronze", "ingot"}, oreDict = {"ingotBronze"})
// ItemCCBase BRONZE_INGOT = new ItemCCBase();
//
// @RegItem(value = {"silver", "ingot"}, oreDict = {"ingotSilver"})
// ItemCCBase SILVER_INGOT = new ItemCCBase();
//
// @RegItem({"bronze", "pickaxe"})
// Item BRONZE_PICKAXE = new ItemCCPickaxe(BRONZE_TOOL_MATERIAL);
//
// @RegItem({"bronze", "axe"})
// Item BRONZE_AXE = new ItemCCAxe(BRONZE_TOOL_MATERIAL, 8.0F, -3.15F);
//
// @RegItem({"bronze", "shovel"})
// Item BRONZE_SHOVEL = new ItemCCSpade(BRONZE_TOOL_MATERIAL);
//
// @RegItem({"bronze", "sword"})
// Item BRONZE_SWORD = new ItemCCSword(BRONZE_TOOL_MATERIAL);
//
// @RegItem({"bronze", "hoe"})
// Item BRONZE_HOE = new ItemCCHoe(BRONZE_TOOL_MATERIAL);
//
// @RegItem({"black","brick"})
// ItemCCBase BLACK_BRICK = new ItemCCBase();
//
// @RegItem({"red", "packet"})
// ItemCCRedPacket RED_PACKET = new ItemCCRedPacket();
//
// @RegItem({"bamboo","item"})
// ItemCCBase BAMBOO_ITEM = new ItemCCBase();
//
// @RegItem({"peeled","bamboo","item"})
// ItemCCBase PEELED_BAMBOO_ITEM = new ItemCCBase();
//
// @RegItem({"art","knife"})
// ItemCCArtKnife ART_KNIFE = new ItemCCArtKnife();
//
// @RegItem({"silk"})
// ItemCCSilk SILK = new ItemCCSilk();
//
// @RegItem(value = {"record", "volunteer", "march"}, oreDict = {"record"})
// ItemCCRecord RECORD_VOLUNTEER_MARCH = new ItemCCRecord("volunteerMarch", CCSounds.VOLUNTEER_MARCH);
//
// @RegItem(value = {"record", "spring", "festival"}, oreDict = {"record"})
// ItemCCRecord RECORD_SPRING_FESTIVAL = new ItemCCRecord("springFestival", CCSounds.SPRING_FESTIVAL);
//
// @RegItem(value = {"record", "mountain", "fall"}, oreDict = {"record"})
// ItemCCRecord RECORD_MOUNTAIN_FALL = new ItemCCRecord("mountainFall", CCSounds.MOUNTAIN_FALL);
//
// @RegItem(value = {"record", "plum", "blossom"}, oreDict = {"record"})
// ItemCCRecord RECORD_PLUM_BLOSSOM = new ItemCCRecord("plumBlossom", CCSounds.PLUM_BLOSSOM);
// }
|
import cn.mccraft.chinacraft.init.CCItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nonnull;
|
return false;
}
});
} else {
this.addSlotToContainer(new Slot(player.inventory, var3, 8 + var3 * 18, 142));
}
}
}
private void load(EntityPlayer player){
//不知道有没有用的防刷物品措施
if(player.getEntityWorld().isRemote) return;
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("item")) {
NBTTagCompound itemnbt = itemStack.getTagCompound().getCompoundTag("item");
//不知道有没有用的防刷物品措施
itemStack.getTagCompound().setTag("item",new NBTTagCompound());
ItemStack item = new ItemStack(itemnbt);
/*if (item != null && FeatureConfig.ItemBombInRedPackerExplosion && item.getItem() == ChinaCraft.bomb) {
//炸弹自爆
player.worldObj.createExplosion(player, player.posX, player.posY, player.posZ, 1.5F, true);
getSlot(0).putStack(null);
} else*/
getSlot(0).putStack(item);
}
}
@Override
public void onContainerClosed(EntityPlayer p_75134_1_) {
super.onContainerClosed(p_75134_1_);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCItems.java
// public interface CCItems {
// Item.ToolMaterial BRONZE_TOOL_MATERIAL = EnumHelper.addToolMaterial("BRONZE", 2, 232, 5.0F, 1.75F, 9);
//
// @RegItem(value = {"copper", "ingot"}, oreDict = {"ingotCopper"})
// ItemCCBase COPPER_INGOT = new ItemCCBase();
//
// @RegItem(value = {"tin", "ingot"}, oreDict = {"ingotTin"})
// ItemCCBase TIN_INGOT = new ItemCCBase();
//
// @RegItem(value = {"bronze", "ingot"}, oreDict = {"ingotBronze"})
// ItemCCBase BRONZE_INGOT = new ItemCCBase();
//
// @RegItem(value = {"silver", "ingot"}, oreDict = {"ingotSilver"})
// ItemCCBase SILVER_INGOT = new ItemCCBase();
//
// @RegItem({"bronze", "pickaxe"})
// Item BRONZE_PICKAXE = new ItemCCPickaxe(BRONZE_TOOL_MATERIAL);
//
// @RegItem({"bronze", "axe"})
// Item BRONZE_AXE = new ItemCCAxe(BRONZE_TOOL_MATERIAL, 8.0F, -3.15F);
//
// @RegItem({"bronze", "shovel"})
// Item BRONZE_SHOVEL = new ItemCCSpade(BRONZE_TOOL_MATERIAL);
//
// @RegItem({"bronze", "sword"})
// Item BRONZE_SWORD = new ItemCCSword(BRONZE_TOOL_MATERIAL);
//
// @RegItem({"bronze", "hoe"})
// Item BRONZE_HOE = new ItemCCHoe(BRONZE_TOOL_MATERIAL);
//
// @RegItem({"black","brick"})
// ItemCCBase BLACK_BRICK = new ItemCCBase();
//
// @RegItem({"red", "packet"})
// ItemCCRedPacket RED_PACKET = new ItemCCRedPacket();
//
// @RegItem({"bamboo","item"})
// ItemCCBase BAMBOO_ITEM = new ItemCCBase();
//
// @RegItem({"peeled","bamboo","item"})
// ItemCCBase PEELED_BAMBOO_ITEM = new ItemCCBase();
//
// @RegItem({"art","knife"})
// ItemCCArtKnife ART_KNIFE = new ItemCCArtKnife();
//
// @RegItem({"silk"})
// ItemCCSilk SILK = new ItemCCSilk();
//
// @RegItem(value = {"record", "volunteer", "march"}, oreDict = {"record"})
// ItemCCRecord RECORD_VOLUNTEER_MARCH = new ItemCCRecord("volunteerMarch", CCSounds.VOLUNTEER_MARCH);
//
// @RegItem(value = {"record", "spring", "festival"}, oreDict = {"record"})
// ItemCCRecord RECORD_SPRING_FESTIVAL = new ItemCCRecord("springFestival", CCSounds.SPRING_FESTIVAL);
//
// @RegItem(value = {"record", "mountain", "fall"}, oreDict = {"record"})
// ItemCCRecord RECORD_MOUNTAIN_FALL = new ItemCCRecord("mountainFall", CCSounds.MOUNTAIN_FALL);
//
// @RegItem(value = {"record", "plum", "blossom"}, oreDict = {"record"})
// ItemCCRecord RECORD_PLUM_BLOSSOM = new ItemCCRecord("plumBlossom", CCSounds.PLUM_BLOSSOM);
// }
// Path: src/main/java/cn/mccraft/chinacraft/inventory/ContainerRedPacket.java
import cn.mccraft.chinacraft.init.CCItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nonnull;
return false;
}
});
} else {
this.addSlotToContainer(new Slot(player.inventory, var3, 8 + var3 * 18, 142));
}
}
}
private void load(EntityPlayer player){
//不知道有没有用的防刷物品措施
if(player.getEntityWorld().isRemote) return;
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("item")) {
NBTTagCompound itemnbt = itemStack.getTagCompound().getCompoundTag("item");
//不知道有没有用的防刷物品措施
itemStack.getTagCompound().setTag("item",new NBTTagCompound());
ItemStack item = new ItemStack(itemnbt);
/*if (item != null && FeatureConfig.ItemBombInRedPackerExplosion && item.getItem() == ChinaCraft.bomb) {
//炸弹自爆
player.worldObj.createExplosion(player, player.posX, player.posY, player.posZ, 1.5F, true);
getSlot(0).putStack(null);
} else*/
getSlot(0).putStack(item);
}
}
@Override
public void onContainerClosed(EntityPlayer p_75134_1_) {
super.onContainerClosed(p_75134_1_);
|
if (p_75134_1_.getHeldItemMainhand() == ItemStack.EMPTY || !p_75134_1_.getHeldItemMainhand().getItem().equals(CCItems.RED_PACKET)) return;
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/crafting/RecipesSilkDyes.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCSilk.java
// public class ItemCCSilk extends ItemCCBase {
// public ItemCCSilk() {
// setCreativeTab(CCCreativeTabs.tabSilkworm);
// }
//
// @Override
// public void addInformation(ItemStack stack, EntityPlayer worldIn, List<String> tooltip, boolean flagIn) {
// tooltip.add(I18n.format("item.silk.lore", stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).getColor()));
// }
//
// @Override
// public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> stacks) {
// try {
// for (EnumDyeColor color : EnumDyeColor.values()) {
// ItemStack stack = new ItemStack(item);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(color.func_176768_e().colorValue);
// stacks.add(stack);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
|
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.chinacraft.item.ItemCCSilk;
import com.google.common.collect.Lists;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import java.util.List;
|
package cn.mccraft.chinacraft.item.crafting;
public class RecipesSilkDyes implements IRecipe {
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
ItemStack itemstack = ItemStack.EMPTY;
List<ItemStack> list = Lists.newArrayList();
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack itemstack1 = inv.getStackInSlot(i);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCSilk.java
// public class ItemCCSilk extends ItemCCBase {
// public ItemCCSilk() {
// setCreativeTab(CCCreativeTabs.tabSilkworm);
// }
//
// @Override
// public void addInformation(ItemStack stack, EntityPlayer worldIn, List<String> tooltip, boolean flagIn) {
// tooltip.add(I18n.format("item.silk.lore", stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).getColor()));
// }
//
// @Override
// public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> stacks) {
// try {
// for (EnumDyeColor color : EnumDyeColor.values()) {
// ItemStack stack = new ItemStack(item);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(color.func_176768_e().colorValue);
// stacks.add(stack);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/crafting/RecipesSilkDyes.java
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.chinacraft.item.ItemCCSilk;
import com.google.common.collect.Lists;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import java.util.List;
package cn.mccraft.chinacraft.item.crafting;
public class RecipesSilkDyes implements IRecipe {
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
ItemStack itemstack = ItemStack.EMPTY;
List<ItemStack> list = Lists.newArrayList();
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack itemstack1 = inv.getStackInSlot(i);
|
if (!itemstack1.isEmpty()) if (itemstack1.getItem() instanceof ItemCCSilk) {
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/crafting/RecipesSilkDyes.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCSilk.java
// public class ItemCCSilk extends ItemCCBase {
// public ItemCCSilk() {
// setCreativeTab(CCCreativeTabs.tabSilkworm);
// }
//
// @Override
// public void addInformation(ItemStack stack, EntityPlayer worldIn, List<String> tooltip, boolean flagIn) {
// tooltip.add(I18n.format("item.silk.lore", stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).getColor()));
// }
//
// @Override
// public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> stacks) {
// try {
// for (EnumDyeColor color : EnumDyeColor.values()) {
// ItemStack stack = new ItemStack(item);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(color.func_176768_e().colorValue);
// stacks.add(stack);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
|
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.chinacraft.item.ItemCCSilk;
import com.google.common.collect.Lists;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import java.util.List;
|
} else {
if (itemstack1.getItem() != Items.DYE)
return false;
list.add(itemstack1);
}
}
return !itemstack.isEmpty() && !list.isEmpty();
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
ItemStack itemstack = ItemStack.EMPTY;
int[] aint = new int[3];
int i = 0;
int j = 0;
ItemCCSilk itemsilk = null;
for (int k = 0; k < inv.getSizeInventory(); ++k) {
ItemStack itemstack1 = inv.getStackInSlot(k);
if (!itemstack1.isEmpty()) if (itemstack1.getItem() instanceof ItemCCSilk) {
itemsilk = (ItemCCSilk) itemstack1.getItem();
if (!itemstack.isEmpty())
return ItemStack.EMPTY;
itemstack = itemstack1.copy();
itemstack.setCount(1);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCSilk.java
// public class ItemCCSilk extends ItemCCBase {
// public ItemCCSilk() {
// setCreativeTab(CCCreativeTabs.tabSilkworm);
// }
//
// @Override
// public void addInformation(ItemStack stack, EntityPlayer worldIn, List<String> tooltip, boolean flagIn) {
// tooltip.add(I18n.format("item.silk.lore", stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).getColor()));
// }
//
// @Override
// public void getSubItems(@Nonnull Item item, CreativeTabs tab, NonNullList<ItemStack> stacks) {
// try {
// for (EnumDyeColor color : EnumDyeColor.values()) {
// ItemStack stack = new ItemStack(item);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(color.func_176768_e().colorValue);
// stacks.add(stack);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/crafting/RecipesSilkDyes.java
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.chinacraft.item.ItemCCSilk;
import com.google.common.collect.Lists;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import java.util.List;
} else {
if (itemstack1.getItem() != Items.DYE)
return false;
list.add(itemstack1);
}
}
return !itemstack.isEmpty() && !list.isEmpty();
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
ItemStack itemstack = ItemStack.EMPTY;
int[] aint = new int[3];
int i = 0;
int j = 0;
ItemCCSilk itemsilk = null;
for (int k = 0; k < inv.getSizeInventory(); ++k) {
ItemStack itemstack1 = inv.getStackInSlot(k);
if (!itemstack1.isEmpty()) if (itemstack1.getItem() instanceof ItemCCSilk) {
itemsilk = (ItemCCSilk) itemstack1.getItem();
if (!itemstack.isEmpty())
return ItemStack.EMPTY;
itemstack = itemstack1.copy();
itemstack.setCount(1);
|
int l = itemstack1.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).getColor();
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCBase.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.Item;
|
package cn.mccraft.chinacraft.item;
/**
* Created by Mouse on 2017/1/28.
*/
public class ItemCCBase extends Item{
public ItemCCBase(){
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCBase.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.Item;
package cn.mccraft.chinacraft.item;
/**
* Created by Mouse on 2017/1/28.
*/
public class ItemCCBase extends Item{
public ItemCCBase(){
|
setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/capability/CapabilitySilkworm.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
|
import cn.mccraft.chinacraft.init.CCCapabilities;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
|
package cn.mccraft.chinacraft.capability;
public class CapabilitySilkworm {
public static class Storage implements Capability.IStorage<Silkworm> {
@Nullable
@Override
public NBTBase writeNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side) {
return new NBTTagInt(instance.getState().ordinal());
}
@Override
public void readNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side, NBTBase nbt) {
instance.setState(SilkwormState.values()[((NBTTagInt) nbt).getInt()]);
}
}
public static class Implementation implements Silkworm {
private SilkwormState state;
@Override
public SilkwormState getState() {
return state;
}
@Override
public void setState(SilkwormState state) {
this.state = state;
}
}
public static class Serializable implements ICapabilitySerializable<NBTTagCompound> {
private Silkworm silkworm = new Implementation();
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
// Path: src/main/java/cn/mccraft/chinacraft/capability/CapabilitySilkworm.java
import cn.mccraft.chinacraft.init.CCCapabilities;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
package cn.mccraft.chinacraft.capability;
public class CapabilitySilkworm {
public static class Storage implements Capability.IStorage<Silkworm> {
@Nullable
@Override
public NBTBase writeNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side) {
return new NBTTagInt(instance.getState().ordinal());
}
@Override
public void readNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side, NBTBase nbt) {
instance.setState(SilkwormState.values()[((NBTTagInt) nbt).getInt()]);
}
}
public static class Implementation implements Silkworm {
private SilkwormState state;
@Override
public SilkwormState getState() {
return state;
}
@Override
public void setState(SilkwormState state) {
this.state = state;
}
}
public static class Serializable implements ICapabilitySerializable<NBTTagCompound> {
private Silkworm silkworm = new Implementation();
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
return capability.equals(CCCapabilities.SILKWORM_CAPABILITY);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/BlockCCSilkwormFrame.java
|
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntitySilkwormFrame.java
// public class TileEntitySilkwormFrame extends TileEntity {
// private IItemHandlerModifiable inventory = new ItemStackHandler(3);
// private ICapabilitySerializable<NBTTagCompound> capabilitySerializable = new CapabilitySilkworm.Serializable();
//
// @Override
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
// return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || capabilitySerializable.hasCapability(capability, facing) || super.hasCapability(capability, facing);
// }
//
// @Nullable
// @Override
// @SuppressWarnings("unchecked")
// public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
// if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
// return (T) inventory;
// else if (capabilitySerializable.hasCapability(capability, facing))
// return capabilitySerializable.getCapability(capability, facing);
// else
// return super.getCapability(capability, facing);
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/gui/EnumGuiType.java
// public enum EnumGuiType {
// RED_PACKET,
// CRUSHER,
// SILKWORM_FRAME
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.block.tileentity.TileEntitySilkwormFrame;
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.common.gui.EnumGuiType;
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
|
package cn.mccraft.chinacraft.block;
public class BlockCCSilkwormFrame extends BlockCCBase {
public BlockCCSilkwormFrame() {
super(Material.WOOD);
|
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntitySilkwormFrame.java
// public class TileEntitySilkwormFrame extends TileEntity {
// private IItemHandlerModifiable inventory = new ItemStackHandler(3);
// private ICapabilitySerializable<NBTTagCompound> capabilitySerializable = new CapabilitySilkworm.Serializable();
//
// @Override
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
// return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || capabilitySerializable.hasCapability(capability, facing) || super.hasCapability(capability, facing);
// }
//
// @Nullable
// @Override
// @SuppressWarnings("unchecked")
// public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
// if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
// return (T) inventory;
// else if (capabilitySerializable.hasCapability(capability, facing))
// return capabilitySerializable.getCapability(capability, facing);
// else
// return super.getCapability(capability, facing);
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/gui/EnumGuiType.java
// public enum EnumGuiType {
// RED_PACKET,
// CRUSHER,
// SILKWORM_FRAME
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCSilkwormFrame.java
import cn.mccraft.chinacraft.block.tileentity.TileEntitySilkwormFrame;
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.common.gui.EnumGuiType;
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
package cn.mccraft.chinacraft.block;
public class BlockCCSilkwormFrame extends BlockCCBase {
public BlockCCSilkwormFrame() {
super(Material.WOOD);
|
setCreativeTab(CCCreativeTabs.tabSilkworm);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/BlockCCSilkwormFrame.java
|
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntitySilkwormFrame.java
// public class TileEntitySilkwormFrame extends TileEntity {
// private IItemHandlerModifiable inventory = new ItemStackHandler(3);
// private ICapabilitySerializable<NBTTagCompound> capabilitySerializable = new CapabilitySilkworm.Serializable();
//
// @Override
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
// return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || capabilitySerializable.hasCapability(capability, facing) || super.hasCapability(capability, facing);
// }
//
// @Nullable
// @Override
// @SuppressWarnings("unchecked")
// public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
// if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
// return (T) inventory;
// else if (capabilitySerializable.hasCapability(capability, facing))
// return capabilitySerializable.getCapability(capability, facing);
// else
// return super.getCapability(capability, facing);
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/gui/EnumGuiType.java
// public enum EnumGuiType {
// RED_PACKET,
// CRUSHER,
// SILKWORM_FRAME
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.block.tileentity.TileEntitySilkwormFrame;
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.common.gui.EnumGuiType;
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
|
package cn.mccraft.chinacraft.block;
public class BlockCCSilkwormFrame extends BlockCCBase {
public BlockCCSilkwormFrame() {
super(Material.WOOD);
setCreativeTab(CCCreativeTabs.tabSilkworm);
}
@Nullable
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
|
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntitySilkwormFrame.java
// public class TileEntitySilkwormFrame extends TileEntity {
// private IItemHandlerModifiable inventory = new ItemStackHandler(3);
// private ICapabilitySerializable<NBTTagCompound> capabilitySerializable = new CapabilitySilkworm.Serializable();
//
// @Override
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
// return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || capabilitySerializable.hasCapability(capability, facing) || super.hasCapability(capability, facing);
// }
//
// @Nullable
// @Override
// @SuppressWarnings("unchecked")
// public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
// if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
// return (T) inventory;
// else if (capabilitySerializable.hasCapability(capability, facing))
// return capabilitySerializable.getCapability(capability, facing);
// else
// return super.getCapability(capability, facing);
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/gui/EnumGuiType.java
// public enum EnumGuiType {
// RED_PACKET,
// CRUSHER,
// SILKWORM_FRAME
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCSilkwormFrame.java
import cn.mccraft.chinacraft.block.tileentity.TileEntitySilkwormFrame;
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.common.gui.EnumGuiType;
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
package cn.mccraft.chinacraft.block;
public class BlockCCSilkwormFrame extends BlockCCBase {
public BlockCCSilkwormFrame() {
super(Material.WOOD);
setCreativeTab(CCCreativeTabs.tabSilkworm);
}
@Nullable
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
|
return new TileEntitySilkwormFrame();
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCPickaxe.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemPickaxe;
|
package cn.mccraft.chinacraft.item;
public class ItemCCPickaxe extends ItemPickaxe{
public ItemCCPickaxe(ToolMaterial material) {
super(material);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCPickaxe.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemPickaxe;
package cn.mccraft.chinacraft.item;
public class ItemCCPickaxe extends ItemPickaxe{
public ItemCCPickaxe(ToolMaterial material) {
super(material);
|
setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCNewSlab.java
|
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCNewSlab.java
// public class BlockCCNewSlab extends BlockCCBase {
//
// public static final PropertyEnum<EnumBlockSlab> SLAB_TYPE = PropertyEnum.<EnumBlockSlab>create("type", EnumBlockSlab.class);
// protected static final AxisAlignedBB AABB_BOTTOM_HALF = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
// protected static final AxisAlignedBB AABB_TOP_HALF = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
//
// public BlockCCNewSlab(Material materialIn) {
// this(materialIn, materialIn.getMaterialMapColor());
// }
//
// public BlockCCNewSlab(Material p_i47249_1_, MapColor p_i47249_2_) {
// super(p_i47249_1_, p_i47249_2_);
// this.setDefaultState(getDefaultState().withProperty(SLAB_TYPE,EnumBlockSlab.BOTTOM));
// this.setLightOpacity(255);
//
// }
//
// protected boolean canSilkHarvest() {
// return false;
// }
//
// public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
// return this.isDouble(state) ? FULL_BLOCK_AABB : (state.getValue(SLAB_TYPE) == EnumBlockSlab.TOP ? AABB_TOP_HALF : AABB_BOTTOM_HALF);
// }
//
// public boolean isFullyOpaque(IBlockState state) {
// return isDouble(state) || state.getValue(SLAB_TYPE) == EnumBlockSlab.TOP;
// }
//
// @Override
// public boolean isFullBlock(IBlockState state) {
// return isDouble(state);
// }
//
// @Override
// public boolean getUseNeighborBrightness(IBlockState state) {
// return !isDouble(state);
// }
//
// public boolean isOpaqueCube(IBlockState state) {
// return this.isDouble(state);
// }
//
// @Override
// public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
// if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
// return super.doesSideBlockRendering(state, world, pos, face);
//
// if (state.isOpaqueCube())
// return true;
//
// EnumBlockSlab side = state.getValue(SLAB_TYPE);
// return (side == EnumBlockSlab.TOP && face == EnumFacing.UP) || (side == EnumBlockSlab.BOTTOM && face == EnumFacing.DOWN);
// }
//
// public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
// IBlockState iblockstate = super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(SLAB_TYPE, EnumBlockSlab.BOTTOM);
// return isDouble(iblockstate) ? iblockstate.withProperty(SLAB_TYPE,EnumBlockSlab.DOUBLE) : (facing != EnumFacing.DOWN && (facing == EnumFacing.UP || (double) hitY <= 0.5D) ? iblockstate : iblockstate.withProperty(SLAB_TYPE, EnumBlockSlab.TOP));
// }
//
// protected BlockStateContainer createBlockState() {
// return new BlockStateContainer(this, SLAB_TYPE);
// }
//
// @Override
// public IBlockState getStateFromMeta(int meta){
// return getDefaultState().withProperty(SLAB_TYPE, meta>=EnumBlockSlab.values().length?EnumBlockSlab.BOTTOM:EnumBlockSlab.values()[meta]);
// }
//
// @Override
// public int getMetaFromState(IBlockState state)
// {
// return state.getValue(SLAB_TYPE).ordinal();
// }
//
// @Override
// public int quantityDropped(IBlockState state, int fortune, Random random) {
// return this.isDouble(state) ? 2 : 1;
// }
//
// public boolean isFullCube(IBlockState state) {
// return this.isDouble(state);
// }
//
// @SideOnly(Side.CLIENT)
// public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
// if (this.isDouble(blockState)) {
// return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
// } else if (side != EnumFacing.UP && side != EnumFacing.DOWN && !super.shouldSideBeRendered(blockState, blockAccess, pos, side)) {
// return false;
// }
// return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
// }
//
// public boolean isDouble(IBlockState state) {
// return state.getValue(SLAB_TYPE) == EnumBlockSlab.DOUBLE;
// }
//
// public static enum EnumBlockSlab implements IStringSerializable {
// TOP("top"),
// BOTTOM("bottom"),
// DOUBLE("double");
//
// private final String name;
//
// private EnumBlockSlab(String name) {
// this.name = name;
// }
//
// public String toString() {
// return this.name;
// }
//
// public String getName() {
// return this.name;
// }
// }
// }
|
import cn.mccraft.chinacraft.block.BlockCCNewSlab;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
|
package cn.mccraft.chinacraft.item;
public class ItemCCNewSlab extends ItemBlock
{
public ItemCCNewSlab(Block block){
super(block);
}
@Override
|
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCNewSlab.java
// public class BlockCCNewSlab extends BlockCCBase {
//
// public static final PropertyEnum<EnumBlockSlab> SLAB_TYPE = PropertyEnum.<EnumBlockSlab>create("type", EnumBlockSlab.class);
// protected static final AxisAlignedBB AABB_BOTTOM_HALF = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
// protected static final AxisAlignedBB AABB_TOP_HALF = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
//
// public BlockCCNewSlab(Material materialIn) {
// this(materialIn, materialIn.getMaterialMapColor());
// }
//
// public BlockCCNewSlab(Material p_i47249_1_, MapColor p_i47249_2_) {
// super(p_i47249_1_, p_i47249_2_);
// this.setDefaultState(getDefaultState().withProperty(SLAB_TYPE,EnumBlockSlab.BOTTOM));
// this.setLightOpacity(255);
//
// }
//
// protected boolean canSilkHarvest() {
// return false;
// }
//
// public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
// return this.isDouble(state) ? FULL_BLOCK_AABB : (state.getValue(SLAB_TYPE) == EnumBlockSlab.TOP ? AABB_TOP_HALF : AABB_BOTTOM_HALF);
// }
//
// public boolean isFullyOpaque(IBlockState state) {
// return isDouble(state) || state.getValue(SLAB_TYPE) == EnumBlockSlab.TOP;
// }
//
// @Override
// public boolean isFullBlock(IBlockState state) {
// return isDouble(state);
// }
//
// @Override
// public boolean getUseNeighborBrightness(IBlockState state) {
// return !isDouble(state);
// }
//
// public boolean isOpaqueCube(IBlockState state) {
// return this.isDouble(state);
// }
//
// @Override
// public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
// if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
// return super.doesSideBlockRendering(state, world, pos, face);
//
// if (state.isOpaqueCube())
// return true;
//
// EnumBlockSlab side = state.getValue(SLAB_TYPE);
// return (side == EnumBlockSlab.TOP && face == EnumFacing.UP) || (side == EnumBlockSlab.BOTTOM && face == EnumFacing.DOWN);
// }
//
// public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
// IBlockState iblockstate = super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(SLAB_TYPE, EnumBlockSlab.BOTTOM);
// return isDouble(iblockstate) ? iblockstate.withProperty(SLAB_TYPE,EnumBlockSlab.DOUBLE) : (facing != EnumFacing.DOWN && (facing == EnumFacing.UP || (double) hitY <= 0.5D) ? iblockstate : iblockstate.withProperty(SLAB_TYPE, EnumBlockSlab.TOP));
// }
//
// protected BlockStateContainer createBlockState() {
// return new BlockStateContainer(this, SLAB_TYPE);
// }
//
// @Override
// public IBlockState getStateFromMeta(int meta){
// return getDefaultState().withProperty(SLAB_TYPE, meta>=EnumBlockSlab.values().length?EnumBlockSlab.BOTTOM:EnumBlockSlab.values()[meta]);
// }
//
// @Override
// public int getMetaFromState(IBlockState state)
// {
// return state.getValue(SLAB_TYPE).ordinal();
// }
//
// @Override
// public int quantityDropped(IBlockState state, int fortune, Random random) {
// return this.isDouble(state) ? 2 : 1;
// }
//
// public boolean isFullCube(IBlockState state) {
// return this.isDouble(state);
// }
//
// @SideOnly(Side.CLIENT)
// public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
// if (this.isDouble(blockState)) {
// return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
// } else if (side != EnumFacing.UP && side != EnumFacing.DOWN && !super.shouldSideBeRendered(blockState, blockAccess, pos, side)) {
// return false;
// }
// return super.shouldSideBeRendered(blockState, blockAccess, pos, side);
// }
//
// public boolean isDouble(IBlockState state) {
// return state.getValue(SLAB_TYPE) == EnumBlockSlab.DOUBLE;
// }
//
// public static enum EnumBlockSlab implements IStringSerializable {
// TOP("top"),
// BOTTOM("bottom"),
// DOUBLE("double");
//
// private final String name;
//
// private EnumBlockSlab(String name) {
// this.name = name;
// }
//
// public String toString() {
// return this.name;
// }
//
// public String getName() {
// return this.name;
// }
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCNewSlab.java
import cn.mccraft.chinacraft.block.BlockCCNewSlab;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
package cn.mccraft.chinacraft.item;
public class ItemCCNewSlab extends ItemBlock
{
public ItemCCNewSlab(Block block){
super(block);
}
@Override
|
public BlockCCNewSlab getBlock() {
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/common/AchievementsLoader.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCAchievements.java
// public interface CCAchievements {
// Achievement FIRST_BRONZE = new Achievement("achievement.firstBronze", "firstBronze", 0, 0, CCItems.BRONZE_INGOT, null);
// Achievement FIRST_BRONZE_PICKAXE = new Achievement("achievement.firstBronzePickaxe", "firstBronzePickaxe", 2, 0, CCItems.BRONZE_PICKAXE, FIRST_BRONZE);
// }
|
import cn.mccraft.chinacraft.init.CCAchievements;
import cn.mccraft.util.loader.Load;
import net.minecraft.stats.Achievement;
import net.minecraftforge.common.AchievementPage;
import net.minecraftforge.fml.common.LoaderState;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Set;
|
package cn.mccraft.chinacraft.common;
public class AchievementsLoader {
private AchievementPage ccAchievementPage;
@Load(LoaderState.POSTINITIALIZATION)
public void registerAchievements() {
Set<Achievement> achievements = new HashSet<>();
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCAchievements.java
// public interface CCAchievements {
// Achievement FIRST_BRONZE = new Achievement("achievement.firstBronze", "firstBronze", 0, 0, CCItems.BRONZE_INGOT, null);
// Achievement FIRST_BRONZE_PICKAXE = new Achievement("achievement.firstBronzePickaxe", "firstBronzePickaxe", 2, 0, CCItems.BRONZE_PICKAXE, FIRST_BRONZE);
// }
// Path: src/main/java/cn/mccraft/chinacraft/common/AchievementsLoader.java
import cn.mccraft.chinacraft.init.CCAchievements;
import cn.mccraft.util.loader.Load;
import net.minecraft.stats.Achievement;
import net.minecraftforge.common.AchievementPage;
import net.minecraftforge.fml.common.LoaderState;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Set;
package cn.mccraft.chinacraft.common;
public class AchievementsLoader {
private AchievementPage ccAchievementPage;
@Load(LoaderState.POSTINITIALIZATION)
public void registerAchievements() {
Set<Achievement> achievements = new HashSet<>();
|
for (Field field : CCAchievements.class.getFields()) {
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCSilk.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.client.resources.I18n;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import javax.annotation.Nonnull;
import java.util.List;
|
package cn.mccraft.chinacraft.item;
public class ItemCCSilk extends ItemCCBase {
public ItemCCSilk() {
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCSilk.java
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.client.resources.I18n;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import javax.annotation.Nonnull;
import java.util.List;
package cn.mccraft.chinacraft.item;
public class ItemCCSilk extends ItemCCBase {
public ItemCCSilk() {
|
setCreativeTab(CCCreativeTabs.tabSilkworm);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCSilk.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.client.resources.I18n;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import javax.annotation.Nonnull;
import java.util.List;
|
package cn.mccraft.chinacraft.item;
public class ItemCCSilk extends ItemCCBase {
public ItemCCSilk() {
setCreativeTab(CCCreativeTabs.tabSilkworm);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer worldIn, List<String> tooltip, boolean flagIn) {
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCSilk.java
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.client.resources.I18n;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import javax.annotation.Nonnull;
import java.util.List;
package cn.mccraft.chinacraft.item;
public class ItemCCSilk extends ItemCCBase {
public ItemCCSilk() {
setCreativeTab(CCCreativeTabs.tabSilkworm);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer worldIn, List<String> tooltip, boolean flagIn) {
|
tooltip.add(I18n.format("item.silk.lore", stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).getColor()));
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/network/RedPacketMessage.java
|
// Path: src/main/java/cn/mccraft/chinacraft/util/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static EntityPlayer getPlayerByUUID(UUID uuid) {
// return FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(uuid);
// }
//
// public static EntityPlayer getPlayerByName(String name) {
// return FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(name);
// }
//
// public static GameProfile getOfflinePlayerByName(String name) {
// for(GameProfile player:FMLCommonHandler.instance().getMinecraftServerInstance().getServerStatusResponse().getPlayers().getPlayers())
// if(player.getName().equalsIgnoreCase(name))
// return player;
// return null;
// }
//
// public static GameProfile getOfflinePlayerByUUID(UUID uuid) {
// for(GameProfile player:FMLCommonHandler.instance().getMinecraftServerInstance().getServerStatusResponse().getPlayers().getPlayers())
// if(player.getId().equals(uuid))
// return player;
// return null;
// }
// }
|
import cn.mccraft.chinacraft.util.Utils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
return sender;
}
public String getWish() {
return wish;
}
public static class Handler implements IMessageHandler<RedPacketMessage, IMessage> {
@Override
public IMessage onMessage(RedPacketMessage message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().player;
ItemStack itemStack = player.inventory.getCurrentItem();
// FIXME if (itemStack == null || itemStack.getItem() != ChinaCraft.redPacket)return null;
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Blocks.AIR));
itemStack = itemStack.copy();
NBTTagCompound nbt = new NBTTagCompound();
nbt.setTag("wish", new NBTTagString(message.getWish()));
nbt.setTag("sender", new NBTTagString(message.getSender()));
itemStack.setTagInfo("redpacket", nbt);
String receiver = message.getReceiver();
if (!message.isSend() || receiver == null || receiver.isEmpty()) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, itemStack);
return null;
}
|
// Path: src/main/java/cn/mccraft/chinacraft/util/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static EntityPlayer getPlayerByUUID(UUID uuid) {
// return FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(uuid);
// }
//
// public static EntityPlayer getPlayerByName(String name) {
// return FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(name);
// }
//
// public static GameProfile getOfflinePlayerByName(String name) {
// for(GameProfile player:FMLCommonHandler.instance().getMinecraftServerInstance().getServerStatusResponse().getPlayers().getPlayers())
// if(player.getName().equalsIgnoreCase(name))
// return player;
// return null;
// }
//
// public static GameProfile getOfflinePlayerByUUID(UUID uuid) {
// for(GameProfile player:FMLCommonHandler.instance().getMinecraftServerInstance().getServerStatusResponse().getPlayers().getPlayers())
// if(player.getId().equals(uuid))
// return player;
// return null;
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/network/RedPacketMessage.java
import cn.mccraft.chinacraft.util.Utils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
return sender;
}
public String getWish() {
return wish;
}
public static class Handler implements IMessageHandler<RedPacketMessage, IMessage> {
@Override
public IMessage onMessage(RedPacketMessage message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().player;
ItemStack itemStack = player.inventory.getCurrentItem();
// FIXME if (itemStack == null || itemStack.getItem() != ChinaCraft.redPacket)return null;
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Blocks.AIR));
itemStack = itemStack.copy();
NBTTagCompound nbt = new NBTTagCompound();
nbt.setTag("wish", new NBTTagString(message.getWish()));
nbt.setTag("sender", new NBTTagString(message.getSender()));
itemStack.setTagInfo("redpacket", nbt);
String receiver = message.getReceiver();
if (!message.isSend() || receiver == null || receiver.isEmpty()) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, itemStack);
return null;
}
|
EntityPlayer reciverPlayer = Utils.getPlayerByName(receiver);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntitySilkwormFrame.java
|
// Path: src/main/java/cn/mccraft/chinacraft/capability/CapabilitySilkworm.java
// public class CapabilitySilkworm {
// public static class Storage implements Capability.IStorage<Silkworm> {
// @Nullable
// @Override
// public NBTBase writeNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side) {
// return new NBTTagInt(instance.getState().ordinal());
// }
//
// @Override
// public void readNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side, NBTBase nbt) {
// instance.setState(SilkwormState.values()[((NBTTagInt) nbt).getInt()]);
// }
// }
//
// public static class Implementation implements Silkworm {
// private SilkwormState state;
//
// @Override
// public SilkwormState getState() {
// return state;
// }
//
// @Override
// public void setState(SilkwormState state) {
// this.state = state;
// }
// }
//
// public static class Serializable implements ICapabilitySerializable<NBTTagCompound> {
// private Silkworm silkworm = new Implementation();
//
// @Override
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
// return capability.equals(CCCapabilities.SILKWORM_CAPABILITY);
// }
//
// @Nullable
// @Override
// @SuppressWarnings("unchecked")
// public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
// return capability.equals(CCCapabilities.SILKWORM_CAPABILITY) ? (T) silkworm : null;
// }
//
// @Override
// public NBTTagCompound serializeNBT() {
// NBTTagCompound compound = new NBTTagCompound();
// compound.setTag("silkworm", CCCapabilities.SILKWORM_CAPABILITY.writeNBT(silkworm, null));
// return compound;
// }
//
// @Override
// public void deserializeNBT(NBTTagCompound nbt) {
// CCCapabilities.SILKWORM_CAPABILITY.readNBT(silkworm, null, nbt.getTag("silkworm"));
// }
// }
// }
|
import cn.mccraft.chinacraft.capability.CapabilitySilkworm;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
|
package cn.mccraft.chinacraft.block.tileentity;
public class TileEntitySilkwormFrame extends TileEntity {
private IItemHandlerModifiable inventory = new ItemStackHandler(3);
|
// Path: src/main/java/cn/mccraft/chinacraft/capability/CapabilitySilkworm.java
// public class CapabilitySilkworm {
// public static class Storage implements Capability.IStorage<Silkworm> {
// @Nullable
// @Override
// public NBTBase writeNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side) {
// return new NBTTagInt(instance.getState().ordinal());
// }
//
// @Override
// public void readNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side, NBTBase nbt) {
// instance.setState(SilkwormState.values()[((NBTTagInt) nbt).getInt()]);
// }
// }
//
// public static class Implementation implements Silkworm {
// private SilkwormState state;
//
// @Override
// public SilkwormState getState() {
// return state;
// }
//
// @Override
// public void setState(SilkwormState state) {
// this.state = state;
// }
// }
//
// public static class Serializable implements ICapabilitySerializable<NBTTagCompound> {
// private Silkworm silkworm = new Implementation();
//
// @Override
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
// return capability.equals(CCCapabilities.SILKWORM_CAPABILITY);
// }
//
// @Nullable
// @Override
// @SuppressWarnings("unchecked")
// public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
// return capability.equals(CCCapabilities.SILKWORM_CAPABILITY) ? (T) silkworm : null;
// }
//
// @Override
// public NBTTagCompound serializeNBT() {
// NBTTagCompound compound = new NBTTagCompound();
// compound.setTag("silkworm", CCCapabilities.SILKWORM_CAPABILITY.writeNBT(silkworm, null));
// return compound;
// }
//
// @Override
// public void deserializeNBT(NBTTagCompound nbt) {
// CCCapabilities.SILKWORM_CAPABILITY.readNBT(silkworm, null, nbt.getTag("silkworm"));
// }
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntitySilkwormFrame.java
import cn.mccraft.chinacraft.capability.CapabilitySilkworm;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
package cn.mccraft.chinacraft.block.tileentity;
public class TileEntitySilkwormFrame extends TileEntity {
private IItemHandlerModifiable inventory = new ItemStackHandler(3);
|
private ICapabilitySerializable<NBTTagCompound> capabilitySerializable = new CapabilitySilkworm.Serializable();
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityCrusher.java
|
// Path: src/main/java/cn/mccraft/chinacraft/api/CCRecipeManager.java
// public class CCRecipeManager {
// private static final Map<Class<? extends ICCRecipe>, Set<ICCRecipe>> RECIPES = new HashMap<>();
//
// public static <T extends ICCRecipe> void addRecipe(Class<T> recipeClass, T recipe) {
// Set<ICCRecipe> recipes = RECIPES.getOrDefault(recipeClass, new HashSet<>());
// recipes.add(recipe);
// RECIPES.put(recipeClass, recipes);
// }
//
// @SuppressWarnings("unchecked")
// @Nullable
// public static <T extends ICCRecipe> Set<T> removeRecipe(Class<T> recipeClass) {
// return (Set<T>) RECIPES.remove(recipeClass);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> void addAllRecipes(Class<T> recipeClass, Set<T> recipeSet) {
// RECIPES.put(recipeClass, recipeSet.stream().collect(Collectors.toSet()));
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Optional<T> getRecipe(Class<T> recipeClass, List<ItemStack> inputs) {
// return RECIPES.getOrDefault(recipeClass, new HashSet<>()).stream().filter(recipe -> recipe.getInputItems().equals(inputs)).findFirst().map(recipe -> (T) recipe);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Set<T> getRecipes(Class<T> recipeClass) {
// return (Set<T>) RECIPES.getOrDefault(recipeClass, new HashSet<>());
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/api/recipe/CrusherRecipe.java
// public class CrusherRecipe extends SimpleOreRecipe {
// private int time;
// private int energy;
// private EnumCrusherMaterial material = EnumCrusherMaterial.STONE;
//
// public int getTime() {
// return time;
// }
//
// public void setTime(int time) {
// this.time = time;
// }
//
// public int getEnergy() {
// return energy;
// }
//
// public void setEnergy(int energy) {
// this.energy = energy;
// }
//
// public EnumCrusherMaterial getMaterial() {
// return material;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/EnumCrusherMaterial.java
// public enum EnumCrusherMaterial implements IStringSerializable {
// // Grey
// STONE(189, 189, 189, 1),
//
// // Deep orange
// BRONZE(255, 171, 145, 1),
//
// // Grey lighten
// IRON(245, 245, 245, 1);
//
// private float r, g, b, a;
//
// EnumCrusherMaterial(int r, int g, int b, int a) {
// Color color = new Color(r, g, b, a);
// this.r = color.getRGBComponents(null)[0];
// this.g = color.getRGBComponents(null)[1];
// this.b = color.getRGBComponents(null)[2];
// this.a = color.getRGBComponents(null)[3];
// }
//
// public float getRed() {
// return r;
// }
//
// public float getGreen() {
// return g;
// }
//
// public float getBlue() {
// return b;
// }
//
// public float getAlpha() {
// return a;
// }
//
// @Override
// public String getName() {
// return this.toString().toLowerCase();
// }
// }
|
import cn.mccraft.chinacraft.api.CCRecipeManager;
import cn.mccraft.chinacraft.api.recipe.CrusherRecipe;
import cn.mccraft.chinacraft.block.machine.EnumCrusherMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Optional;
|
package cn.mccraft.chinacraft.block.tileentity;
public class TileEntityCrusher extends TileEntity implements ITickable {
// 槽1:主原料 槽2:副原料 槽3:主产出 槽4:副产出
private ItemStackHandler inventory = new ItemStackHandler(4);
|
// Path: src/main/java/cn/mccraft/chinacraft/api/CCRecipeManager.java
// public class CCRecipeManager {
// private static final Map<Class<? extends ICCRecipe>, Set<ICCRecipe>> RECIPES = new HashMap<>();
//
// public static <T extends ICCRecipe> void addRecipe(Class<T> recipeClass, T recipe) {
// Set<ICCRecipe> recipes = RECIPES.getOrDefault(recipeClass, new HashSet<>());
// recipes.add(recipe);
// RECIPES.put(recipeClass, recipes);
// }
//
// @SuppressWarnings("unchecked")
// @Nullable
// public static <T extends ICCRecipe> Set<T> removeRecipe(Class<T> recipeClass) {
// return (Set<T>) RECIPES.remove(recipeClass);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> void addAllRecipes(Class<T> recipeClass, Set<T> recipeSet) {
// RECIPES.put(recipeClass, recipeSet.stream().collect(Collectors.toSet()));
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Optional<T> getRecipe(Class<T> recipeClass, List<ItemStack> inputs) {
// return RECIPES.getOrDefault(recipeClass, new HashSet<>()).stream().filter(recipe -> recipe.getInputItems().equals(inputs)).findFirst().map(recipe -> (T) recipe);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Set<T> getRecipes(Class<T> recipeClass) {
// return (Set<T>) RECIPES.getOrDefault(recipeClass, new HashSet<>());
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/api/recipe/CrusherRecipe.java
// public class CrusherRecipe extends SimpleOreRecipe {
// private int time;
// private int energy;
// private EnumCrusherMaterial material = EnumCrusherMaterial.STONE;
//
// public int getTime() {
// return time;
// }
//
// public void setTime(int time) {
// this.time = time;
// }
//
// public int getEnergy() {
// return energy;
// }
//
// public void setEnergy(int energy) {
// this.energy = energy;
// }
//
// public EnumCrusherMaterial getMaterial() {
// return material;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/EnumCrusherMaterial.java
// public enum EnumCrusherMaterial implements IStringSerializable {
// // Grey
// STONE(189, 189, 189, 1),
//
// // Deep orange
// BRONZE(255, 171, 145, 1),
//
// // Grey lighten
// IRON(245, 245, 245, 1);
//
// private float r, g, b, a;
//
// EnumCrusherMaterial(int r, int g, int b, int a) {
// Color color = new Color(r, g, b, a);
// this.r = color.getRGBComponents(null)[0];
// this.g = color.getRGBComponents(null)[1];
// this.b = color.getRGBComponents(null)[2];
// this.a = color.getRGBComponents(null)[3];
// }
//
// public float getRed() {
// return r;
// }
//
// public float getGreen() {
// return g;
// }
//
// public float getBlue() {
// return b;
// }
//
// public float getAlpha() {
// return a;
// }
//
// @Override
// public String getName() {
// return this.toString().toLowerCase();
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityCrusher.java
import cn.mccraft.chinacraft.api.CCRecipeManager;
import cn.mccraft.chinacraft.api.recipe.CrusherRecipe;
import cn.mccraft.chinacraft.block.machine.EnumCrusherMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Optional;
package cn.mccraft.chinacraft.block.tileentity;
public class TileEntityCrusher extends TileEntity implements ITickable {
// 槽1:主原料 槽2:副原料 槽3:主产出 槽4:副产出
private ItemStackHandler inventory = new ItemStackHandler(4);
|
private EnumCrusherMaterial crusherMaterial;
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityCrusher.java
|
// Path: src/main/java/cn/mccraft/chinacraft/api/CCRecipeManager.java
// public class CCRecipeManager {
// private static final Map<Class<? extends ICCRecipe>, Set<ICCRecipe>> RECIPES = new HashMap<>();
//
// public static <T extends ICCRecipe> void addRecipe(Class<T> recipeClass, T recipe) {
// Set<ICCRecipe> recipes = RECIPES.getOrDefault(recipeClass, new HashSet<>());
// recipes.add(recipe);
// RECIPES.put(recipeClass, recipes);
// }
//
// @SuppressWarnings("unchecked")
// @Nullable
// public static <T extends ICCRecipe> Set<T> removeRecipe(Class<T> recipeClass) {
// return (Set<T>) RECIPES.remove(recipeClass);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> void addAllRecipes(Class<T> recipeClass, Set<T> recipeSet) {
// RECIPES.put(recipeClass, recipeSet.stream().collect(Collectors.toSet()));
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Optional<T> getRecipe(Class<T> recipeClass, List<ItemStack> inputs) {
// return RECIPES.getOrDefault(recipeClass, new HashSet<>()).stream().filter(recipe -> recipe.getInputItems().equals(inputs)).findFirst().map(recipe -> (T) recipe);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Set<T> getRecipes(Class<T> recipeClass) {
// return (Set<T>) RECIPES.getOrDefault(recipeClass, new HashSet<>());
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/api/recipe/CrusherRecipe.java
// public class CrusherRecipe extends SimpleOreRecipe {
// private int time;
// private int energy;
// private EnumCrusherMaterial material = EnumCrusherMaterial.STONE;
//
// public int getTime() {
// return time;
// }
//
// public void setTime(int time) {
// this.time = time;
// }
//
// public int getEnergy() {
// return energy;
// }
//
// public void setEnergy(int energy) {
// this.energy = energy;
// }
//
// public EnumCrusherMaterial getMaterial() {
// return material;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/EnumCrusherMaterial.java
// public enum EnumCrusherMaterial implements IStringSerializable {
// // Grey
// STONE(189, 189, 189, 1),
//
// // Deep orange
// BRONZE(255, 171, 145, 1),
//
// // Grey lighten
// IRON(245, 245, 245, 1);
//
// private float r, g, b, a;
//
// EnumCrusherMaterial(int r, int g, int b, int a) {
// Color color = new Color(r, g, b, a);
// this.r = color.getRGBComponents(null)[0];
// this.g = color.getRGBComponents(null)[1];
// this.b = color.getRGBComponents(null)[2];
// this.a = color.getRGBComponents(null)[3];
// }
//
// public float getRed() {
// return r;
// }
//
// public float getGreen() {
// return g;
// }
//
// public float getBlue() {
// return b;
// }
//
// public float getAlpha() {
// return a;
// }
//
// @Override
// public String getName() {
// return this.toString().toLowerCase();
// }
// }
|
import cn.mccraft.chinacraft.api.CCRecipeManager;
import cn.mccraft.chinacraft.api.recipe.CrusherRecipe;
import cn.mccraft.chinacraft.block.machine.EnumCrusherMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Optional;
|
package cn.mccraft.chinacraft.block.tileentity;
public class TileEntityCrusher extends TileEntity implements ITickable {
// 槽1:主原料 槽2:副原料 槽3:主产出 槽4:副产出
private ItemStackHandler inventory = new ItemStackHandler(4);
private EnumCrusherMaterial crusherMaterial;
private EnergyStorage energyStorage = new EnergyStorage(10000);
private int progress = 0;
|
// Path: src/main/java/cn/mccraft/chinacraft/api/CCRecipeManager.java
// public class CCRecipeManager {
// private static final Map<Class<? extends ICCRecipe>, Set<ICCRecipe>> RECIPES = new HashMap<>();
//
// public static <T extends ICCRecipe> void addRecipe(Class<T> recipeClass, T recipe) {
// Set<ICCRecipe> recipes = RECIPES.getOrDefault(recipeClass, new HashSet<>());
// recipes.add(recipe);
// RECIPES.put(recipeClass, recipes);
// }
//
// @SuppressWarnings("unchecked")
// @Nullable
// public static <T extends ICCRecipe> Set<T> removeRecipe(Class<T> recipeClass) {
// return (Set<T>) RECIPES.remove(recipeClass);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> void addAllRecipes(Class<T> recipeClass, Set<T> recipeSet) {
// RECIPES.put(recipeClass, recipeSet.stream().collect(Collectors.toSet()));
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Optional<T> getRecipe(Class<T> recipeClass, List<ItemStack> inputs) {
// return RECIPES.getOrDefault(recipeClass, new HashSet<>()).stream().filter(recipe -> recipe.getInputItems().equals(inputs)).findFirst().map(recipe -> (T) recipe);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Set<T> getRecipes(Class<T> recipeClass) {
// return (Set<T>) RECIPES.getOrDefault(recipeClass, new HashSet<>());
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/api/recipe/CrusherRecipe.java
// public class CrusherRecipe extends SimpleOreRecipe {
// private int time;
// private int energy;
// private EnumCrusherMaterial material = EnumCrusherMaterial.STONE;
//
// public int getTime() {
// return time;
// }
//
// public void setTime(int time) {
// this.time = time;
// }
//
// public int getEnergy() {
// return energy;
// }
//
// public void setEnergy(int energy) {
// this.energy = energy;
// }
//
// public EnumCrusherMaterial getMaterial() {
// return material;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/EnumCrusherMaterial.java
// public enum EnumCrusherMaterial implements IStringSerializable {
// // Grey
// STONE(189, 189, 189, 1),
//
// // Deep orange
// BRONZE(255, 171, 145, 1),
//
// // Grey lighten
// IRON(245, 245, 245, 1);
//
// private float r, g, b, a;
//
// EnumCrusherMaterial(int r, int g, int b, int a) {
// Color color = new Color(r, g, b, a);
// this.r = color.getRGBComponents(null)[0];
// this.g = color.getRGBComponents(null)[1];
// this.b = color.getRGBComponents(null)[2];
// this.a = color.getRGBComponents(null)[3];
// }
//
// public float getRed() {
// return r;
// }
//
// public float getGreen() {
// return g;
// }
//
// public float getBlue() {
// return b;
// }
//
// public float getAlpha() {
// return a;
// }
//
// @Override
// public String getName() {
// return this.toString().toLowerCase();
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityCrusher.java
import cn.mccraft.chinacraft.api.CCRecipeManager;
import cn.mccraft.chinacraft.api.recipe.CrusherRecipe;
import cn.mccraft.chinacraft.block.machine.EnumCrusherMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Optional;
package cn.mccraft.chinacraft.block.tileentity;
public class TileEntityCrusher extends TileEntity implements ITickable {
// 槽1:主原料 槽2:副原料 槽3:主产出 槽4:副产出
private ItemStackHandler inventory = new ItemStackHandler(4);
private EnumCrusherMaterial crusherMaterial;
private EnergyStorage energyStorage = new EnergyStorage(10000);
private int progress = 0;
|
private CrusherRecipe currentRecipe;
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityCrusher.java
|
// Path: src/main/java/cn/mccraft/chinacraft/api/CCRecipeManager.java
// public class CCRecipeManager {
// private static final Map<Class<? extends ICCRecipe>, Set<ICCRecipe>> RECIPES = new HashMap<>();
//
// public static <T extends ICCRecipe> void addRecipe(Class<T> recipeClass, T recipe) {
// Set<ICCRecipe> recipes = RECIPES.getOrDefault(recipeClass, new HashSet<>());
// recipes.add(recipe);
// RECIPES.put(recipeClass, recipes);
// }
//
// @SuppressWarnings("unchecked")
// @Nullable
// public static <T extends ICCRecipe> Set<T> removeRecipe(Class<T> recipeClass) {
// return (Set<T>) RECIPES.remove(recipeClass);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> void addAllRecipes(Class<T> recipeClass, Set<T> recipeSet) {
// RECIPES.put(recipeClass, recipeSet.stream().collect(Collectors.toSet()));
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Optional<T> getRecipe(Class<T> recipeClass, List<ItemStack> inputs) {
// return RECIPES.getOrDefault(recipeClass, new HashSet<>()).stream().filter(recipe -> recipe.getInputItems().equals(inputs)).findFirst().map(recipe -> (T) recipe);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Set<T> getRecipes(Class<T> recipeClass) {
// return (Set<T>) RECIPES.getOrDefault(recipeClass, new HashSet<>());
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/api/recipe/CrusherRecipe.java
// public class CrusherRecipe extends SimpleOreRecipe {
// private int time;
// private int energy;
// private EnumCrusherMaterial material = EnumCrusherMaterial.STONE;
//
// public int getTime() {
// return time;
// }
//
// public void setTime(int time) {
// this.time = time;
// }
//
// public int getEnergy() {
// return energy;
// }
//
// public void setEnergy(int energy) {
// this.energy = energy;
// }
//
// public EnumCrusherMaterial getMaterial() {
// return material;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/EnumCrusherMaterial.java
// public enum EnumCrusherMaterial implements IStringSerializable {
// // Grey
// STONE(189, 189, 189, 1),
//
// // Deep orange
// BRONZE(255, 171, 145, 1),
//
// // Grey lighten
// IRON(245, 245, 245, 1);
//
// private float r, g, b, a;
//
// EnumCrusherMaterial(int r, int g, int b, int a) {
// Color color = new Color(r, g, b, a);
// this.r = color.getRGBComponents(null)[0];
// this.g = color.getRGBComponents(null)[1];
// this.b = color.getRGBComponents(null)[2];
// this.a = color.getRGBComponents(null)[3];
// }
//
// public float getRed() {
// return r;
// }
//
// public float getGreen() {
// return g;
// }
//
// public float getBlue() {
// return b;
// }
//
// public float getAlpha() {
// return a;
// }
//
// @Override
// public String getName() {
// return this.toString().toLowerCase();
// }
// }
|
import cn.mccraft.chinacraft.api.CCRecipeManager;
import cn.mccraft.chinacraft.api.recipe.CrusherRecipe;
import cn.mccraft.chinacraft.block.machine.EnumCrusherMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Optional;
|
compound = super.writeToNBT(compound);
compound.setTag("inventory", inventory.serializeNBT());
compound.setTag("energy", CapabilityEnergy.ENERGY.getStorage().writeNBT(CapabilityEnergy.ENERGY, energyStorage, null));
compound.setTag("inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().writeNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventory, null));
return compound;
}
public EnumCrusherMaterial getCrusherMaterial() {
return crusherMaterial;
}
@Override
public void update() {
if (currentRecipe != null && progress != 0) {
if (progress == currentRecipe.getTime()) { // 达到时间, 输出
inventory.setStackInSlot(0, ItemStack.EMPTY);
inventory.setStackInSlot(1, ItemStack.EMPTY);
inventory.setStackInSlot(2, currentRecipe.getOutputItems().get(0));
inventory.setStackInSlot(3, currentRecipe.getOutputItems().get(1));
currentRecipe = null;
progress = 0;
} else {
// 继续运转
++progress;
}
} else if (progress != 0)
// 清理
progress = 0;
else {
progress = 0;
|
// Path: src/main/java/cn/mccraft/chinacraft/api/CCRecipeManager.java
// public class CCRecipeManager {
// private static final Map<Class<? extends ICCRecipe>, Set<ICCRecipe>> RECIPES = new HashMap<>();
//
// public static <T extends ICCRecipe> void addRecipe(Class<T> recipeClass, T recipe) {
// Set<ICCRecipe> recipes = RECIPES.getOrDefault(recipeClass, new HashSet<>());
// recipes.add(recipe);
// RECIPES.put(recipeClass, recipes);
// }
//
// @SuppressWarnings("unchecked")
// @Nullable
// public static <T extends ICCRecipe> Set<T> removeRecipe(Class<T> recipeClass) {
// return (Set<T>) RECIPES.remove(recipeClass);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> void addAllRecipes(Class<T> recipeClass, Set<T> recipeSet) {
// RECIPES.put(recipeClass, recipeSet.stream().collect(Collectors.toSet()));
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Optional<T> getRecipe(Class<T> recipeClass, List<ItemStack> inputs) {
// return RECIPES.getOrDefault(recipeClass, new HashSet<>()).stream().filter(recipe -> recipe.getInputItems().equals(inputs)).findFirst().map(recipe -> (T) recipe);
// }
//
// @SuppressWarnings("unchecked")
// public static <T extends ICCRecipe> Set<T> getRecipes(Class<T> recipeClass) {
// return (Set<T>) RECIPES.getOrDefault(recipeClass, new HashSet<>());
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/api/recipe/CrusherRecipe.java
// public class CrusherRecipe extends SimpleOreRecipe {
// private int time;
// private int energy;
// private EnumCrusherMaterial material = EnumCrusherMaterial.STONE;
//
// public int getTime() {
// return time;
// }
//
// public void setTime(int time) {
// this.time = time;
// }
//
// public int getEnergy() {
// return energy;
// }
//
// public void setEnergy(int energy) {
// this.energy = energy;
// }
//
// public EnumCrusherMaterial getMaterial() {
// return material;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/EnumCrusherMaterial.java
// public enum EnumCrusherMaterial implements IStringSerializable {
// // Grey
// STONE(189, 189, 189, 1),
//
// // Deep orange
// BRONZE(255, 171, 145, 1),
//
// // Grey lighten
// IRON(245, 245, 245, 1);
//
// private float r, g, b, a;
//
// EnumCrusherMaterial(int r, int g, int b, int a) {
// Color color = new Color(r, g, b, a);
// this.r = color.getRGBComponents(null)[0];
// this.g = color.getRGBComponents(null)[1];
// this.b = color.getRGBComponents(null)[2];
// this.a = color.getRGBComponents(null)[3];
// }
//
// public float getRed() {
// return r;
// }
//
// public float getGreen() {
// return g;
// }
//
// public float getBlue() {
// return b;
// }
//
// public float getAlpha() {
// return a;
// }
//
// @Override
// public String getName() {
// return this.toString().toLowerCase();
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityCrusher.java
import cn.mccraft.chinacraft.api.CCRecipeManager;
import cn.mccraft.chinacraft.api.recipe.CrusherRecipe;
import cn.mccraft.chinacraft.block.machine.EnumCrusherMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.EnergyStorage;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Optional;
compound = super.writeToNBT(compound);
compound.setTag("inventory", inventory.serializeNBT());
compound.setTag("energy", CapabilityEnergy.ENERGY.getStorage().writeNBT(CapabilityEnergy.ENERGY, energyStorage, null));
compound.setTag("inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().writeNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventory, null));
return compound;
}
public EnumCrusherMaterial getCrusherMaterial() {
return crusherMaterial;
}
@Override
public void update() {
if (currentRecipe != null && progress != 0) {
if (progress == currentRecipe.getTime()) { // 达到时间, 输出
inventory.setStackInSlot(0, ItemStack.EMPTY);
inventory.setStackInSlot(1, ItemStack.EMPTY);
inventory.setStackInSlot(2, currentRecipe.getOutputItems().get(0));
inventory.setStackInSlot(3, currentRecipe.getOutputItems().get(1));
currentRecipe = null;
progress = 0;
} else {
// 继续运转
++progress;
}
} else if (progress != 0)
// 清理
progress = 0;
else {
progress = 0;
|
Optional<CrusherRecipe> recipe = CCRecipeManager.getRecipe(CrusherRecipe.class, Arrays.asList(inventory.getStackInSlot(0), inventory.getStackInSlot(1)));
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/common/TileEntityLoader.java
|
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityCrusher.java
// public class TileEntityCrusher extends TileEntity implements ITickable {
// // 槽1:主原料 槽2:副原料 槽3:主产出 槽4:副产出
// private ItemStackHandler inventory = new ItemStackHandler(4);
// private EnumCrusherMaterial crusherMaterial;
// private EnergyStorage energyStorage = new EnergyStorage(10000);
//
// private int progress = 0;
// private CrusherRecipe currentRecipe;
//
// public TileEntityCrusher(EnumCrusherMaterial crusherMaterial) {
// this.crusherMaterial = crusherMaterial;
// FMLCommonHandler.instance().getMinecraftServerInstance().registerTickable(this);
// }
//
// @Override
// public void readFromNBT(NBTTagCompound compound) {
// super.readFromNBT(compound);
// inventory.deserializeNBT(compound.getCompoundTag("inventory"));
// CapabilityEnergy.ENERGY.getStorage().readNBT(CapabilityEnergy.ENERGY, energyStorage, null, compound.getTag("energy"));
// CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().readNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventory, null, compound.getTag("inventory"));
// }
//
// @Nonnull
// @Override
// public NBTTagCompound writeToNBT(NBTTagCompound compound) {
// compound = super.writeToNBT(compound);
// compound.setTag("inventory", inventory.serializeNBT());
// compound.setTag("energy", CapabilityEnergy.ENERGY.getStorage().writeNBT(CapabilityEnergy.ENERGY, energyStorage, null));
// compound.setTag("inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().writeNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventory, null));
// return compound;
// }
//
// public EnumCrusherMaterial getCrusherMaterial() {
// return crusherMaterial;
// }
//
// @Override
// public void update() {
// if (currentRecipe != null && progress != 0) {
// if (progress == currentRecipe.getTime()) { // 达到时间, 输出
// inventory.setStackInSlot(0, ItemStack.EMPTY);
// inventory.setStackInSlot(1, ItemStack.EMPTY);
// inventory.setStackInSlot(2, currentRecipe.getOutputItems().get(0));
// inventory.setStackInSlot(3, currentRecipe.getOutputItems().get(1));
// currentRecipe = null;
// progress = 0;
// } else {
// // 继续运转
// ++progress;
// }
// } else if (progress != 0)
// // 清理
// progress = 0;
// else {
// progress = 0;
// Optional<CrusherRecipe> recipe = CCRecipeManager.getRecipe(CrusherRecipe.class, Arrays.asList(inventory.getStackInSlot(0), inventory.getStackInSlot(1)));
// recipe.ifPresent(crusherRecipe -> currentRecipe = crusherRecipe);
// if (energyStorage.getEnergyStored() >= currentRecipe.getEnergy() && energyStorage.canExtract())
// energyStorage.extractEnergy(currentRecipe.getEnergy(), false);
// }
// }
//
// public int getProgress() {
// return progress;
// }
//
// public int getCurrentMaxProgress() {
// return currentRecipe != null ? currentRecipe.getTime() : 0;
// }
//
// public void setProgress(int progress) {
// this.progress = progress;
// }
//
// public ItemStackHandler getInventory() {
// return inventory;
// }
//
// @Override
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
// return capability == CapabilityEnergy.ENERGY || capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
// }
//
// @SuppressWarnings("unchecked")
// @Nullable
// @Override
// public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
// return capability == CapabilityEnergy.ENERGY ? (T) energyStorage : capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T) inventory : super.getCapability(capability, facing);
// }
// }
|
import cn.mccraft.chinacraft.block.tileentity.TileEntityCrusher;
import cn.mccraft.util.loader.Load;
import net.minecraftforge.fml.common.LoaderState;
import net.minecraftforge.fml.common.registry.GameRegistry;
|
package cn.mccraft.chinacraft.common;
public class TileEntityLoader {
@Load(LoaderState.INITIALIZATION)
public void load() {
|
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityCrusher.java
// public class TileEntityCrusher extends TileEntity implements ITickable {
// // 槽1:主原料 槽2:副原料 槽3:主产出 槽4:副产出
// private ItemStackHandler inventory = new ItemStackHandler(4);
// private EnumCrusherMaterial crusherMaterial;
// private EnergyStorage energyStorage = new EnergyStorage(10000);
//
// private int progress = 0;
// private CrusherRecipe currentRecipe;
//
// public TileEntityCrusher(EnumCrusherMaterial crusherMaterial) {
// this.crusherMaterial = crusherMaterial;
// FMLCommonHandler.instance().getMinecraftServerInstance().registerTickable(this);
// }
//
// @Override
// public void readFromNBT(NBTTagCompound compound) {
// super.readFromNBT(compound);
// inventory.deserializeNBT(compound.getCompoundTag("inventory"));
// CapabilityEnergy.ENERGY.getStorage().readNBT(CapabilityEnergy.ENERGY, energyStorage, null, compound.getTag("energy"));
// CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().readNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventory, null, compound.getTag("inventory"));
// }
//
// @Nonnull
// @Override
// public NBTTagCompound writeToNBT(NBTTagCompound compound) {
// compound = super.writeToNBT(compound);
// compound.setTag("inventory", inventory.serializeNBT());
// compound.setTag("energy", CapabilityEnergy.ENERGY.getStorage().writeNBT(CapabilityEnergy.ENERGY, energyStorage, null));
// compound.setTag("inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().writeNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventory, null));
// return compound;
// }
//
// public EnumCrusherMaterial getCrusherMaterial() {
// return crusherMaterial;
// }
//
// @Override
// public void update() {
// if (currentRecipe != null && progress != 0) {
// if (progress == currentRecipe.getTime()) { // 达到时间, 输出
// inventory.setStackInSlot(0, ItemStack.EMPTY);
// inventory.setStackInSlot(1, ItemStack.EMPTY);
// inventory.setStackInSlot(2, currentRecipe.getOutputItems().get(0));
// inventory.setStackInSlot(3, currentRecipe.getOutputItems().get(1));
// currentRecipe = null;
// progress = 0;
// } else {
// // 继续运转
// ++progress;
// }
// } else if (progress != 0)
// // 清理
// progress = 0;
// else {
// progress = 0;
// Optional<CrusherRecipe> recipe = CCRecipeManager.getRecipe(CrusherRecipe.class, Arrays.asList(inventory.getStackInSlot(0), inventory.getStackInSlot(1)));
// recipe.ifPresent(crusherRecipe -> currentRecipe = crusherRecipe);
// if (energyStorage.getEnergyStored() >= currentRecipe.getEnergy() && energyStorage.canExtract())
// energyStorage.extractEnergy(currentRecipe.getEnergy(), false);
// }
// }
//
// public int getProgress() {
// return progress;
// }
//
// public int getCurrentMaxProgress() {
// return currentRecipe != null ? currentRecipe.getTime() : 0;
// }
//
// public void setProgress(int progress) {
// this.progress = progress;
// }
//
// public ItemStackHandler getInventory() {
// return inventory;
// }
//
// @Override
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
// return capability == CapabilityEnergy.ENERGY || capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
// }
//
// @SuppressWarnings("unchecked")
// @Nullable
// @Override
// public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
// return capability == CapabilityEnergy.ENERGY ? (T) energyStorage : capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T) inventory : super.getCapability(capability, facing);
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/common/TileEntityLoader.java
import cn.mccraft.chinacraft.block.tileentity.TileEntityCrusher;
import cn.mccraft.util.loader.Load;
import net.minecraftforge.fml.common.LoaderState;
import net.minecraftforge.fml.common.registry.GameRegistry;
package cn.mccraft.chinacraft.common;
public class TileEntityLoader {
@Load(LoaderState.INITIALIZATION)
public void load() {
|
GameRegistry.registerTileEntity(TileEntityCrusher.class, ChinaCraft.MODID + ":crusher");
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/common/SoundLoader.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCSounds.java
// public interface CCSounds {
// SoundEvent VOLUNTEER_MARCH = new SoundEvent(new ResourceLocation(ChinaCraft.MODID, "record.volunteer_march"));
// SoundEvent SPRING_FESTIVAL = new SoundEvent(new ResourceLocation(ChinaCraft.MODID, "record.spring_festival"));
// SoundEvent MOUNTAIN_FALL = new SoundEvent(new ResourceLocation(ChinaCraft.MODID, "record.mountain_fall"));
// SoundEvent PLUM_BLOSSOM = new SoundEvent(new ResourceLocation(ChinaCraft.MODID, "record.plum_blossom"));
// }
|
import cn.mccraft.chinacraft.init.CCSounds;
import cn.mccraft.util.loader.Load;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import java.util.Arrays;
|
package cn.mccraft.chinacraft.common;
public class SoundLoader {
@Load
public void loadSounds() {
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCSounds.java
// public interface CCSounds {
// SoundEvent VOLUNTEER_MARCH = new SoundEvent(new ResourceLocation(ChinaCraft.MODID, "record.volunteer_march"));
// SoundEvent SPRING_FESTIVAL = new SoundEvent(new ResourceLocation(ChinaCraft.MODID, "record.spring_festival"));
// SoundEvent MOUNTAIN_FALL = new SoundEvent(new ResourceLocation(ChinaCraft.MODID, "record.mountain_fall"));
// SoundEvent PLUM_BLOSSOM = new SoundEvent(new ResourceLocation(ChinaCraft.MODID, "record.plum_blossom"));
// }
// Path: src/main/java/cn/mccraft/chinacraft/common/SoundLoader.java
import cn.mccraft.chinacraft.init.CCSounds;
import cn.mccraft.util.loader.Load;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import java.util.Arrays;
package cn.mccraft.chinacraft.common;
public class SoundLoader {
@Load
public void loadSounds() {
|
Arrays.stream(CCSounds.class.getFields()).map(field -> {
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCSpade.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemSpade;
|
package cn.mccraft.chinacraft.item;
public class ItemCCSpade extends ItemSpade{
public ItemCCSpade(ToolMaterial material) {
super(material);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCSpade.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemSpade;
package cn.mccraft.chinacraft.item;
public class ItemCCSpade extends ItemSpade{
public ItemCCSpade(ToolMaterial material) {
super(material);
|
setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/machine/BlockMachine.java
|
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCBase.java
// public class BlockCCBase extends Block{
//
// public BlockCCBase(Material materialIn) {
// this(materialIn, materialIn.getMaterialMapColor());
// }
//
// public BlockCCBase(Material materialIn, MapColor blockMapColorIn) {
// super(materialIn,blockMapColorIn);
// setCreativeTab(CCCreativeTabs.tabCore);
// }
//
// public BlockCCBase setHarvestLevelReturnBlock(String toolClass, int level) {
// super.setHarvestLevel(toolClass, level);
// return this;
// }
//
// @Override
// public BlockCCBase setSoundType(SoundType sound)
// {
// super.setSoundType(sound);
// return this;
// }
//
// public float getResistance(){
// return blockResistance / 3.0F;
// }
//
// public float getHardness(){
// return blockHardness / 5.0F;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCMaterials.java
// public interface CCMaterials {
// Material MACHINE_MATERIAL = new Material(MapColor.BROWN);
// }
|
import cn.mccraft.chinacraft.block.BlockCCBase;
import cn.mccraft.chinacraft.init.CCMaterials;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
|
package cn.mccraft.chinacraft.block.machine;
public abstract class BlockMachine extends BlockCCBase implements ITileEntityProvider {
public BlockMachine() {
|
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCBase.java
// public class BlockCCBase extends Block{
//
// public BlockCCBase(Material materialIn) {
// this(materialIn, materialIn.getMaterialMapColor());
// }
//
// public BlockCCBase(Material materialIn, MapColor blockMapColorIn) {
// super(materialIn,blockMapColorIn);
// setCreativeTab(CCCreativeTabs.tabCore);
// }
//
// public BlockCCBase setHarvestLevelReturnBlock(String toolClass, int level) {
// super.setHarvestLevel(toolClass, level);
// return this;
// }
//
// @Override
// public BlockCCBase setSoundType(SoundType sound)
// {
// super.setSoundType(sound);
// return this;
// }
//
// public float getResistance(){
// return blockResistance / 3.0F;
// }
//
// public float getHardness(){
// return blockHardness / 5.0F;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCMaterials.java
// public interface CCMaterials {
// Material MACHINE_MATERIAL = new Material(MapColor.BROWN);
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/BlockMachine.java
import cn.mccraft.chinacraft.block.BlockCCBase;
import cn.mccraft.chinacraft.init.CCMaterials;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
package cn.mccraft.chinacraft.block.machine;
public abstract class BlockMachine extends BlockCCBase implements ITileEntityProvider {
public BlockMachine() {
|
super(CCMaterials.MACHINE_MATERIAL);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/capability/CapabilityColor.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
|
import cn.mccraft.chinacraft.init.CCCapabilities;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
|
package cn.mccraft.chinacraft.capability;
public class CapabilityColor {
public static class Storage implements Capability.IStorage<ItemStackColorable> {
@Nullable
@Override
public NBTBase writeNBT(Capability<ItemStackColorable> capability, ItemStackColorable instance, EnumFacing side) {
return new NBTTagInt(instance.getColor());
}
@Override
public void readNBT(Capability<ItemStackColorable> capability, ItemStackColorable instance, EnumFacing side, NBTBase nbt) {
instance.setColor(((NBTTagInt) nbt).getInt());
}
}
public static class Implementation implements ItemStackColorable {
private int color;
@Override
public int getColor() {
return color;
}
@Override
public void setColor(int color) {
this.color = color;
}
}
public static class Serializable implements ICapabilitySerializable<NBTTagCompound> {
private ItemStackColorable colorable = new CapabilityColor.Implementation();
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
// Path: src/main/java/cn/mccraft/chinacraft/capability/CapabilityColor.java
import cn.mccraft.chinacraft.init.CCCapabilities;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
package cn.mccraft.chinacraft.capability;
public class CapabilityColor {
public static class Storage implements Capability.IStorage<ItemStackColorable> {
@Nullable
@Override
public NBTBase writeNBT(Capability<ItemStackColorable> capability, ItemStackColorable instance, EnumFacing side) {
return new NBTTagInt(instance.getColor());
}
@Override
public void readNBT(Capability<ItemStackColorable> capability, ItemStackColorable instance, EnumFacing side, NBTBase nbt) {
instance.setColor(((NBTTagInt) nbt).getInt());
}
}
public static class Implementation implements ItemStackColorable {
private int color;
@Override
public int getColor() {
return color;
}
@Override
public void setColor(int color) {
this.color = color;
}
}
public static class Serializable implements ICapabilitySerializable<NBTTagCompound> {
private ItemStackColorable colorable = new CapabilityColor.Implementation();
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
return capability.equals(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCRedPacket.java
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/gui/EnumGuiType.java
// public enum EnumGuiType {
// RED_PACKET,
// CRUSHER,
// SILKWORM_FRAME
// }
|
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.common.gui.EnumGuiType;import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
|
package cn.mccraft.chinacraft.item;
public class ItemCCRedPacket extends ItemCCBase {
public ItemCCRedPacket(){
setMaxStackSize(1);
}
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
BlockPos pos = playerIn.getPosition();
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/gui/EnumGuiType.java
// public enum EnumGuiType {
// RED_PACKET,
// CRUSHER,
// SILKWORM_FRAME
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCRedPacket.java
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.common.gui.EnumGuiType;import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
package cn.mccraft.chinacraft.item;
public class ItemCCRedPacket extends ItemCCBase {
public ItemCCRedPacket(){
setMaxStackSize(1);
}
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
BlockPos pos = playerIn.getPosition();
|
playerIn.openGui(ChinaCraft.getInstance(), EnumGuiType.RED_PACKET.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCRedPacket.java
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/gui/EnumGuiType.java
// public enum EnumGuiType {
// RED_PACKET,
// CRUSHER,
// SILKWORM_FRAME
// }
|
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.common.gui.EnumGuiType;import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
|
package cn.mccraft.chinacraft.item;
public class ItemCCRedPacket extends ItemCCBase {
public ItemCCRedPacket(){
setMaxStackSize(1);
}
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
BlockPos pos = playerIn.getPosition();
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/common/gui/EnumGuiType.java
// public enum EnumGuiType {
// RED_PACKET,
// CRUSHER,
// SILKWORM_FRAME
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCRedPacket.java
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.common.gui.EnumGuiType;import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
package cn.mccraft.chinacraft.item;
public class ItemCCRedPacket extends ItemCCBase {
public ItemCCRedPacket(){
setMaxStackSize(1);
}
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
BlockPos pos = playerIn.getPosition();
|
playerIn.openGui(ChinaCraft.getInstance(), EnumGuiType.RED_PACKET.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
|
UnknownStudio/ChinaCraft2
|
src/main/extern/cn/mccraft/util/loader/Proxy.java
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
|
import cn.mccraft.chinacraft.common.ChinaCraft;
import net.minecraftforge.fml.common.LoaderState;
import net.minecraftforge.fml.common.event.FMLStateEvent;
import net.minecraftforge.fml.relauncher.Side;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
|
package cn.mccraft.util.loader;
/**
* 动态代理.
* 请在主类中监听你要进行注册的{@link FMLStateEvent} 并调用{@link #invoke(FMLStateEvent, LoaderState, Side)}函数.
*
*/
public interface Proxy {
default <T extends FMLStateEvent> void invoke (T event, LoaderState state, Side side) {
getStateLoaderMap().values().forEach(methods -> methods.forEach(method -> {
if (method.getAnnotation(Load.class).side().equals(side))
if (method.getParameterCount() == 0 && method.getAnnotation(Load.class).value().equals(state))
try {
method.invoke(getLoaderInstanceMap().get(method.getDeclaringClass()));
} catch (IllegalAccessException | InvocationTargetException e) {
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
// Path: src/main/extern/cn/mccraft/util/loader/Proxy.java
import cn.mccraft.chinacraft.common.ChinaCraft;
import net.minecraftforge.fml.common.LoaderState;
import net.minecraftforge.fml.common.event.FMLStateEvent;
import net.minecraftforge.fml.relauncher.Side;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
package cn.mccraft.util.loader;
/**
* 动态代理.
* 请在主类中监听你要进行注册的{@link FMLStateEvent} 并调用{@link #invoke(FMLStateEvent, LoaderState, Side)}函数.
*
*/
public interface Proxy {
default <T extends FMLStateEvent> void invoke (T event, LoaderState state, Side side) {
getStateLoaderMap().values().forEach(methods -> methods.forEach(method -> {
if (method.getAnnotation(Load.class).side().equals(side))
if (method.getParameterCount() == 0 && method.getAnnotation(Load.class).value().equals(state))
try {
method.invoke(getLoaderInstanceMap().get(method.getDeclaringClass()));
} catch (IllegalAccessException | InvocationTargetException e) {
|
ChinaCraft.getLogger().warn("Un-able to invoke method " + method.getName(), e);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/BlockCrank.java
|
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/BlockCrusher.java
// public class BlockCrusher extends BlockMachine {
// private EnumCrusherMaterial crusherMaterial;
//
// public BlockCrusher(EnumCrusherMaterial crusherMaterial) {
// this.crusherMaterial = crusherMaterial;
// }
//
// @Nullable
// @Override
// public TileEntity createNewTileEntity(World worldIn, int meta) {
// return new TileEntityCrusher(crusherMaterial);
// }
//
// @Override
// public boolean isFullCube(IBlockState state) {
// return false;
// }
//
// @Override
// public boolean isOpaqueCube(IBlockState state) {
// return false;
// }
//
// @Override
// public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
// return new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
// }
//
// @Override
// public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
// ItemStack stack) {
// int l = MathHelper.floor(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
//
// if (l == 0) {
// worldIn.setBlockState(pos, state.getBlock().getStateFromMeta(4));
// }
//
// if (l == 1) {
// worldIn.setBlockState(pos, state.getBlock().getStateFromMeta(5));
// }
//
// if (l == 2) {
// worldIn.setBlockState(pos, state.getBlock().getStateFromMeta(2));
// }
//
// if (l == 3) {
// worldIn.setBlockState(pos, state.getBlock().getStateFromMeta(3));
// }
// }
//
// @Override
// public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float side, float hitX, float hitY) {
// if (playerIn.isSneaking() || worldIn.isRemote)
// return true;
// else
// playerIn.openGui(ChinaCraft.getInstance(), EnumGuiType.CRUSHER.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
// return true;
// }
// }
|
import cn.mccraft.chinacraft.block.machine.BlockCrusher;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.energy.CapabilityEnergy;
import javax.annotation.Nonnull;
import java.util.Optional;
|
package cn.mccraft.chinacraft.block;
public class BlockCrank extends BlockCCBase {
public BlockCrank() {
super(Material.WOOD);
}
@Override
public boolean canPlaceBlockAt(World worldIn, @Nonnull BlockPos pos) {
|
// Path: src/main/java/cn/mccraft/chinacraft/block/machine/BlockCrusher.java
// public class BlockCrusher extends BlockMachine {
// private EnumCrusherMaterial crusherMaterial;
//
// public BlockCrusher(EnumCrusherMaterial crusherMaterial) {
// this.crusherMaterial = crusherMaterial;
// }
//
// @Nullable
// @Override
// public TileEntity createNewTileEntity(World worldIn, int meta) {
// return new TileEntityCrusher(crusherMaterial);
// }
//
// @Override
// public boolean isFullCube(IBlockState state) {
// return false;
// }
//
// @Override
// public boolean isOpaqueCube(IBlockState state) {
// return false;
// }
//
// @Override
// public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
// return new AxisAlignedBB(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
// }
//
// @Override
// public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
// ItemStack stack) {
// int l = MathHelper.floor(placer.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
//
// if (l == 0) {
// worldIn.setBlockState(pos, state.getBlock().getStateFromMeta(4));
// }
//
// if (l == 1) {
// worldIn.setBlockState(pos, state.getBlock().getStateFromMeta(5));
// }
//
// if (l == 2) {
// worldIn.setBlockState(pos, state.getBlock().getStateFromMeta(2));
// }
//
// if (l == 3) {
// worldIn.setBlockState(pos, state.getBlock().getStateFromMeta(3));
// }
// }
//
// @Override
// public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float side, float hitX, float hitY) {
// if (playerIn.isSneaking() || worldIn.isRemote)
// return true;
// else
// playerIn.openGui(ChinaCraft.getInstance(), EnumGuiType.CRUSHER.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
// return true;
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCrank.java
import cn.mccraft.chinacraft.block.machine.BlockCrusher;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.energy.CapabilityEnergy;
import javax.annotation.Nonnull;
import java.util.Optional;
package cn.mccraft.chinacraft.block;
public class BlockCrank extends BlockCCBase {
public BlockCrank() {
super(Material.WOOD);
}
@Override
public boolean canPlaceBlockAt(World worldIn, @Nonnull BlockPos pos) {
|
return worldIn.getBlockState(pos.down()).getBlock() instanceof BlockCrusher;
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCDoor.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.item.ItemDoor;
|
package cn.mccraft.chinacraft.item;
public class ItemCCDoor extends ItemDoor {
public ItemCCDoor(Block block) {
super(block);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCDoor.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.item.ItemDoor;
package cn.mccraft.chinacraft.item;
public class ItemCCDoor extends ItemDoor {
public ItemCCDoor(Block block) {
super(block);
|
setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCSword.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemSword;
|
package cn.mccraft.chinacraft.item;
public class ItemCCSword extends ItemSword{
public ItemCCSword(ToolMaterial material) {
super(material);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCSword.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemSword;
package cn.mccraft.chinacraft.item;
public class ItemCCSword extends ItemSword{
public ItemCCSword(ToolMaterial material) {
super(material);
|
setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/BlockCCSlab.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Random;
|
package cn.mccraft.chinacraft.block;
public class BlockCCSlab extends BlockSlab{
public static final PropertyEnum<EnumType> VARIANT = PropertyEnum.<EnumType>create("variant", EnumType.class);
private final boolean isDouble;
private final BlockCCSlab singleSlab;
public BlockCCSlab(Material materialIn,boolean isDouble,BlockCCSlab singleSlab) {
super(materialIn);
this.isDouble = isDouble;
this.useNeighborBrightness = !isDouble;
this.singleSlab = singleSlab==null?this:singleSlab;
IBlockState iblockstate = this.blockState.getBaseState();
if (!this.isDouble())
{
iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCSlab.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.BlockSlab;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Random;
package cn.mccraft.chinacraft.block;
public class BlockCCSlab extends BlockSlab{
public static final PropertyEnum<EnumType> VARIANT = PropertyEnum.<EnumType>create("variant", EnumType.class);
private final boolean isDouble;
private final BlockCCSlab singleSlab;
public BlockCCSlab(Material materialIn,boolean isDouble,BlockCCSlab singleSlab) {
super(materialIn);
this.isDouble = isDouble;
this.useNeighborBrightness = !isDouble;
this.singleSlab = singleSlab==null?this:singleSlab;
IBlockState iblockstate = this.blockState.getBaseState();
if (!this.isDouble())
{
iblockstate = iblockstate.withProperty(HALF, BlockSlab.EnumBlockHalf.BOTTOM);
|
setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/capability/CapabilityLoader.java
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
|
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.util.loader.Load;
import cn.mccraft.chinacraft.util.loader.annotation.RegCapability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.lang.reflect.Field;
|
package cn.mccraft.chinacraft.capability;
public class CapabilityLoader {
@Load
public void load(FMLPreInitializationEvent event) {
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
// Path: src/main/java/cn/mccraft/chinacraft/capability/CapabilityLoader.java
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.util.loader.Load;
import cn.mccraft.chinacraft.util.loader.annotation.RegCapability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.lang.reflect.Field;
package cn.mccraft.chinacraft.capability;
public class CapabilityLoader {
@Load
public void load(FMLPreInitializationEvent event) {
|
for (Field field : CCCapabilities.class.getFields()) {
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/capability/CapabilityLoader.java
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
|
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.util.loader.Load;
import cn.mccraft.chinacraft.util.loader.annotation.RegCapability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.lang.reflect.Field;
|
package cn.mccraft.chinacraft.capability;
public class CapabilityLoader {
@Load
public void load(FMLPreInitializationEvent event) {
for (Field field : CCCapabilities.class.getFields()) {
try {
register(field.getAnnotation(CapabilityInject.class).value(), field.getAnnotation(RegCapability.class));
} catch (Exception e) {
|
// Path: src/main/java/cn/mccraft/chinacraft/common/ChinaCraft.java
// @Mod(modid = ChinaCraft.MODID, name = ChinaCraft.NAME, version = ChinaCraft.VERSION, dependencies = "required-after:biomesoplenty")
// public final class ChinaCraft {
// public static final String MODID = "chinacraft";
// public static final String NAME = "ChinaCraft 2";
// public static final String VERSION = "0.0.1";
//
// @SidedProxy(clientSide = "cn.mccraft.chinacraft.client.ClientProxy", serverSide = "cn.mccraft.chinacraft.common.CommonProxy")
// private static CommonProxy proxy;
//
// @Mod.Instance(ChinaCraft.MODID)
// private static ChinaCraft instance;
//
// private CCEventHandler eventHandler;
//
// private static SimpleNetworkWrapper network;
//
// private static final Logger LOGGER = LogManager.getLogger(MODID);
//
// private JsonSettings settings;
//
// @EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// settings = new JsonSettings(event.getModConfigurationDirectory(), "config");
// proxy.preInit(event);
// eventHandler = new CCEventHandler();
// }
//
// @EventHandler
// public void init(FMLInitializationEvent event) {
// network = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
// network.registerMessage(new RedPacketMessage.Handler(), RedPacketMessage.class,0, Side.SERVER);
//
// NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
//
// proxy.init(event);
// }
//
// @EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// proxy.postInit(event);
// }
//
// @EventHandler
// public void loadComplete(FMLLoadCompleteEvent event) {
// proxy.loadComplete(event);
// }
//
// public JsonSettings getSettings() {
// return settings;
// }
//
// public CCEventHandler getEventHandler() {
// return eventHandler;
// }
//
// public static Logger getLogger() {
// return LOGGER;
// }
//
// public static ChinaCraft getInstance() {
// return instance;
// }
//
// public static SimpleNetworkWrapper getNetwork() {
// return network;
// }
//
// public static CommonProxy getProxy() {
// return proxy;
// }
// }
//
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
// @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
// @CapabilityInject(CrusherStats.class)
// Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
// @CapabilityInject(ItemStackColorable.class)
// Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
//
// @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
// @CapabilityInject(Silkworm.class)
// Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }
// Path: src/main/java/cn/mccraft/chinacraft/capability/CapabilityLoader.java
import cn.mccraft.chinacraft.common.ChinaCraft;
import cn.mccraft.chinacraft.init.CCCapabilities;
import cn.mccraft.util.loader.Load;
import cn.mccraft.chinacraft.util.loader.annotation.RegCapability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.lang.reflect.Field;
package cn.mccraft.chinacraft.capability;
public class CapabilityLoader {
@Load
public void load(FMLPreInitializationEvent event) {
for (Field field : CCCapabilities.class.getFields()) {
try {
register(field.getAnnotation(CapabilityInject.class).value(), field.getAnnotation(RegCapability.class));
} catch (Exception e) {
|
ChinaCraft.getLogger().warn("Un-able to register capability " + field.toGenericString(), e);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/BlockCCFlower.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
|
package cn.mccraft.chinacraft.block;
public class BlockCCFlower extends BlockCCBase implements IPlantable {
protected static final AxisAlignedBB FLOWER_AABB = new AxisAlignedBB(0.30000001192092896D, 0.0D, 0.30000001192092896D, 0.699999988079071D, 0.6000000238418579D, 0.699999988079071D);
public BlockCCFlower() {
super(Material.PLANTS);
setTickRandomly(true);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCFlower.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
package cn.mccraft.chinacraft.block;
public class BlockCCFlower extends BlockCCBase implements IPlantable {
protected static final AxisAlignedBB FLOWER_AABB = new AxisAlignedBB(0.30000001192092896D, 0.0D, 0.30000001192092896D, 0.699999988079071D, 0.6000000238418579D, 0.699999988079071D);
public BlockCCFlower() {
super(Material.PLANTS);
setTickRandomly(true);
|
setCreativeTab(CCCreativeTabs.tabPlant);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/BlockCCSapling.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.BlockBush;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.event.terraingen.TerrainGen;
import java.util.Random;
|
package cn.mccraft.chinacraft.block;
public class BlockCCSapling extends BlockBush implements IGrowable {
public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1);
protected static final AxisAlignedBB SAPLING_AABB = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D);
private WorldGenerator treeGen;
public BlockCCSapling(WorldGenerator treeGen) {
this(Material.PLANTS, treeGen);
}
public BlockCCSapling(Material material, WorldGenerator treeGen) {
super(material);
this.treeGen = treeGen;
this.setDefaultState(this.blockState.getBaseState().withProperty(STAGE, Integer.valueOf(0)));
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCSapling.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.BlockBush;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.event.terraingen.TerrainGen;
import java.util.Random;
package cn.mccraft.chinacraft.block;
public class BlockCCSapling extends BlockBush implements IGrowable {
public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1);
protected static final AxisAlignedBB SAPLING_AABB = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D);
private WorldGenerator treeGen;
public BlockCCSapling(WorldGenerator treeGen) {
this(Material.PLANTS, treeGen);
}
public BlockCCSapling(Material material, WorldGenerator treeGen) {
super(material);
this.treeGen = treeGen;
this.setDefaultState(this.blockState.getBaseState().withProperty(STAGE, Integer.valueOf(0)));
|
this.setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/BlockCCBase.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
|
package cn.mccraft.chinacraft.block;
/**
* Base block of ChinaCraft.
* Extend this block in your own blocks.
* ChinaCraft基础方块类,请在你的自定义方块中继承该类。
*/
public class BlockCCBase extends Block{
public BlockCCBase(Material materialIn) {
this(materialIn, materialIn.getMaterialMapColor());
}
public BlockCCBase(Material materialIn, MapColor blockMapColorIn) {
super(materialIn,blockMapColorIn);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCBase.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
package cn.mccraft.chinacraft.block;
/**
* Base block of ChinaCraft.
* Extend this block in your own blocks.
* ChinaCraft基础方块类,请在你的自定义方块中继承该类。
*/
public class BlockCCBase extends Block{
public BlockCCBase(Material materialIn) {
this(materialIn, materialIn.getMaterialMapColor());
}
public BlockCCBase(Material materialIn, MapColor blockMapColorIn) {
super(materialIn,blockMapColorIn);
|
setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/BlockCCLamp.java
|
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityLamp.java
// public class TileEntityLamp extends TileEntity implements ITickable {
// private boolean isBurning;
//
// @Override
// public void update() {
//
// }
// }
|
import cn.mccraft.chinacraft.block.tileentity.TileEntityLamp;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import javax.annotation.Nullable;
|
package cn.mccraft.chinacraft.block;
public class BlockCCLamp extends BlockCCBase {
protected static final AxisAlignedBB LAMP_AABB = new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 0.75D, 0.75D);
protected static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 3);
protected static final PropertyBool ON = PropertyBool.create("on");
private boolean isBurning;
public BlockCCLamp() {
super(Material.CIRCUITS);
setDefaultState(blockState.getBaseState().withProperty(LEVEL, 0));
isBurning = false;
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Nullable
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
|
// Path: src/main/java/cn/mccraft/chinacraft/block/tileentity/TileEntityLamp.java
// public class TileEntityLamp extends TileEntity implements ITickable {
// private boolean isBurning;
//
// @Override
// public void update() {
//
// }
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCLamp.java
import cn.mccraft.chinacraft.block.tileentity.TileEntityLamp;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import javax.annotation.Nullable;
package cn.mccraft.chinacraft.block;
public class BlockCCLamp extends BlockCCBase {
protected static final AxisAlignedBB LAMP_AABB = new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 0.75D, 0.75D);
protected static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 3);
protected static final PropertyBool ON = PropertyBool.create("on");
private boolean isBurning;
public BlockCCLamp() {
super(Material.CIRCUITS);
setDefaultState(blockState.getBaseState().withProperty(LEVEL, 0));
isBurning = false;
}
@Override
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Nullable
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
|
return new TileEntityLamp();
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/block/BlockCCStairs.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
|
package cn.mccraft.chinacraft.block;
public class BlockCCStairs extends BlockStairs{
public BlockCCStairs(IBlockState modelState) {
super(modelState);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/block/BlockCCStairs.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
package cn.mccraft.chinacraft.block;
public class BlockCCStairs extends BlockStairs{
public BlockCCStairs(IBlockState modelState) {
super(modelState);
|
setCreativeTab(CCCreativeTabs.tabCore);
|
UnknownStudio/ChinaCraft2
|
src/main/java/cn/mccraft/chinacraft/item/ItemCCAxe.java
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
|
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemAxe;
|
package cn.mccraft.chinacraft.item;
/**
* Created by Mouse on 2017/2/4.
*/
public class ItemCCAxe extends ItemAxe{
public ItemCCAxe(ToolMaterial material) {
super(material);
|
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCreativeTabs.java
// public interface CCCreativeTabs {
// CreativeTabs tabCore = new CreativeTabs(ChinaCraft.MODID + "Core") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.COPPER_ORE);
// }
// };
//
// CreativeTabs tabMaterials = new CreativeTabs(ChinaCraft.MODID + "Materials") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCItems.BRONZE_INGOT);
// }
// };
//
// CreativeTabs tabSilkworm = new CreativeTabs(ChinaCraft.MODID + "Silkworm") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// ItemStack stack = new ItemStack(CCItems.SILK);
// stack.getCapability(CCCapabilities.ITEM_STACK_COLORABLE_CAPABILITY, null).setColor(EnumDyeColor.WHITE.func_176768_e().colorValue);
// return stack;
// }
// };
//
// CreativeTabs tabPlant = new CreativeTabs(ChinaCraft.MODID + "Plant") {
// @Nonnull
// @Override
// public ItemStack getTabIconItem() {
// return new ItemStack(CCBlocks.AZALEA);
// }
// };
// }
// Path: src/main/java/cn/mccraft/chinacraft/item/ItemCCAxe.java
import cn.mccraft.chinacraft.init.CCCreativeTabs;
import net.minecraft.item.ItemAxe;
package cn.mccraft.chinacraft.item;
/**
* Created by Mouse on 2017/2/4.
*/
public class ItemCCAxe extends ItemAxe{
public ItemCCAxe(ToolMaterial material) {
super(material);
|
setCreativeTab(CCCreativeTabs.tabCore);
|
quartzweb/quartz-web
|
src/main/java/com/github/quartzweb/service/strategy/SchedulerServiceStrategyParameter.java
|
// Path: src/main/java/com/github/quartzweb/exception/UnsupportedTranslateException.java
// public class UnsupportedTranslateException extends RuntimeException {
//
// public UnsupportedTranslateException() {
// }
//
// public UnsupportedTranslateException(String message) {
// super(message);
// }
//
// public UnsupportedTranslateException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public UnsupportedTranslateException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/com/github/quartzweb/service/HttpParameterNameConstants.java
// public abstract class HttpParameterNameConstants {
//
// /**
// * 关于Scheduler
// */
// public static class Scheduler {
//
// /** Scheduler - schedule名称 */
// public static final String NAME = "schedulerName";
//
// /** Scheduler - 延时秒数 - 单位(秒) */
// public static final String DELAYED = "delayed";
//
// }
//
//
// /**
// * 关于Job操作
// */
// public static class Job {
// /** Job操作 - job名称 */
// public static final String NAME = "jobName";
//
// /** Job操作 - job分组 */
// public static final String GROUP = "jobGroup";
//
// /** Job操作 - jobDataMap数据 -key值 */
// public static final String DATA_MAP_KEY_PREFIX = "jobDataMapKey_";
//
// /** Job操作 - jobDataMap数据 -value值 */
// public static final String DATA_MAP_VALUE_PREFIX = "jobDataMapValue_";
//
// /** Job操作 - JobClass,*/
// public static final String JOB_CLASS = "jobClass";
//
// /** Job操作 - Job类型*/
// public static final String JOB_TYPE = "jobType";
//
// /** Job操作 - job描述 */
// public static final String DESCRIPTION = "description";
//
// /** Job操作 - JobClass参数名称前缀 */
// public static final String JOB_CLASS_PARAM_TYPE_NAME_PREFIX = "jobClassParamType_";
//
// /** Job操作 - JobClass参数值前缀 */
// public static final String JOB_CLASS_PARAM_TYPE_VALUE_PREFIX = "jobClassParamTypeValue_";
//
// /** Job操作 - 执行方法类型 */
// public static final String METHOD_INVOKER_TYPE = "methodInvokerType";
//
// /** Job操作 - 执行方法名称 */
// public static final String JOB_CLASS_METHOD_NAME = "jobClassMethodName";
// /** Job操作 - 执行method类型前缀*/
// public static final String JOB_CLASS_METHOD_PARAM_TYPE_NAME_PREFIX = "jobClassMethodParamType_";
//
// /** Job操作 - 执行method参数值前缀 */
// public static final String JOB_CLASS_METHOD_PARAM_TYPE_VALUE_PREFIX = "jobClassMethodParamTypeValue_";
//
// }
//
//
// public static class Trigger {
//
// /** Trigger操作 - trigger名称 */
// public static final String NAME = "triggerName";
//
//
// /** HTTP参数名称 - Trigger操作 - job分组 */
// public static final String GROUP = "triggerGroup";
//
// /** trigger描述 */
// public static final String DESCRIPTION = "description";
//
// /** 优先级 */
// public static final String PRIORITY = "priority";
//
// /** cron表达式 */
// public static final String CRONEXPRESSION = "cronExpression";
//
// /** trigger 开始时间 */
// public static final String START_DATE = "startDate";
//
// /** trigger 结束时间 */
// public static final String END_DATE = "endDate";
//
// }
//
//
// public static class Validate{
// /** 对比是否为子类的Class名称 */
// public static final String ASSIGNABLE_CLASS_NAME= "assignableClassName";
//
// /** Class名称 */
// public static final String CLASS_NAME= "className";
//
// /** cron表达式 */
// public static final String CRON_EXPRESSION= "cronExpression";
// }
//
//
// }
|
import javax.servlet.http.HttpServletRequest;
import com.github.quartzweb.exception.UnsupportedTranslateException;
import com.github.quartzweb.service.HttpParameterNameConstants;
|
/**
* Licensed under the Apache License, Version 2.0 (the "License");
*/
package com.github.quartzweb.service.strategy;
/**
* @author quxiucheng [[email protected]]
*/
public class SchedulerServiceStrategyParameter implements ServiceStrategyParameter {
/**
* scheduler名称
*/
private String schedulerName;
/**
* 延迟启动秒数
*/
private String delayed;
/**
* 获取 scheduler名称
* @return schedulerName scheduler名称
*/
public String getSchedulerName() {
return this.schedulerName;
}
/**
* 设置 scheduler名称
* @param schedulerName scheduler名称
*/
public void setSchedulerName(String schedulerName) {
this.schedulerName = schedulerName;
}
/**
* 获取 延迟启动秒数
* @return delayed 延迟启动秒数
*/
public String getDelayed() {
return this.delayed;
}
/**
* 设置 延迟启动秒数
* @param delayed 延迟启动秒数
*/
public void setDelayed(String delayed) {
this.delayed = delayed;
}
/**
* 转换成SchedulerServiceStrategyParameter
* @param object 转换bean
* @return SchedulerServiceStrategyParameter实体类
*/
|
// Path: src/main/java/com/github/quartzweb/exception/UnsupportedTranslateException.java
// public class UnsupportedTranslateException extends RuntimeException {
//
// public UnsupportedTranslateException() {
// }
//
// public UnsupportedTranslateException(String message) {
// super(message);
// }
//
// public UnsupportedTranslateException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public UnsupportedTranslateException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/com/github/quartzweb/service/HttpParameterNameConstants.java
// public abstract class HttpParameterNameConstants {
//
// /**
// * 关于Scheduler
// */
// public static class Scheduler {
//
// /** Scheduler - schedule名称 */
// public static final String NAME = "schedulerName";
//
// /** Scheduler - 延时秒数 - 单位(秒) */
// public static final String DELAYED = "delayed";
//
// }
//
//
// /**
// * 关于Job操作
// */
// public static class Job {
// /** Job操作 - job名称 */
// public static final String NAME = "jobName";
//
// /** Job操作 - job分组 */
// public static final String GROUP = "jobGroup";
//
// /** Job操作 - jobDataMap数据 -key值 */
// public static final String DATA_MAP_KEY_PREFIX = "jobDataMapKey_";
//
// /** Job操作 - jobDataMap数据 -value值 */
// public static final String DATA_MAP_VALUE_PREFIX = "jobDataMapValue_";
//
// /** Job操作 - JobClass,*/
// public static final String JOB_CLASS = "jobClass";
//
// /** Job操作 - Job类型*/
// public static final String JOB_TYPE = "jobType";
//
// /** Job操作 - job描述 */
// public static final String DESCRIPTION = "description";
//
// /** Job操作 - JobClass参数名称前缀 */
// public static final String JOB_CLASS_PARAM_TYPE_NAME_PREFIX = "jobClassParamType_";
//
// /** Job操作 - JobClass参数值前缀 */
// public static final String JOB_CLASS_PARAM_TYPE_VALUE_PREFIX = "jobClassParamTypeValue_";
//
// /** Job操作 - 执行方法类型 */
// public static final String METHOD_INVOKER_TYPE = "methodInvokerType";
//
// /** Job操作 - 执行方法名称 */
// public static final String JOB_CLASS_METHOD_NAME = "jobClassMethodName";
// /** Job操作 - 执行method类型前缀*/
// public static final String JOB_CLASS_METHOD_PARAM_TYPE_NAME_PREFIX = "jobClassMethodParamType_";
//
// /** Job操作 - 执行method参数值前缀 */
// public static final String JOB_CLASS_METHOD_PARAM_TYPE_VALUE_PREFIX = "jobClassMethodParamTypeValue_";
//
// }
//
//
// public static class Trigger {
//
// /** Trigger操作 - trigger名称 */
// public static final String NAME = "triggerName";
//
//
// /** HTTP参数名称 - Trigger操作 - job分组 */
// public static final String GROUP = "triggerGroup";
//
// /** trigger描述 */
// public static final String DESCRIPTION = "description";
//
// /** 优先级 */
// public static final String PRIORITY = "priority";
//
// /** cron表达式 */
// public static final String CRONEXPRESSION = "cronExpression";
//
// /** trigger 开始时间 */
// public static final String START_DATE = "startDate";
//
// /** trigger 结束时间 */
// public static final String END_DATE = "endDate";
//
// }
//
//
// public static class Validate{
// /** 对比是否为子类的Class名称 */
// public static final String ASSIGNABLE_CLASS_NAME= "assignableClassName";
//
// /** Class名称 */
// public static final String CLASS_NAME= "className";
//
// /** cron表达式 */
// public static final String CRON_EXPRESSION= "cronExpression";
// }
//
//
// }
// Path: src/main/java/com/github/quartzweb/service/strategy/SchedulerServiceStrategyParameter.java
import javax.servlet.http.HttpServletRequest;
import com.github.quartzweb.exception.UnsupportedTranslateException;
import com.github.quartzweb.service.HttpParameterNameConstants;
/**
* Licensed under the Apache License, Version 2.0 (the "License");
*/
package com.github.quartzweb.service.strategy;
/**
* @author quxiucheng [[email protected]]
*/
public class SchedulerServiceStrategyParameter implements ServiceStrategyParameter {
/**
* scheduler名称
*/
private String schedulerName;
/**
* 延迟启动秒数
*/
private String delayed;
/**
* 获取 scheduler名称
* @return schedulerName scheduler名称
*/
public String getSchedulerName() {
return this.schedulerName;
}
/**
* 设置 scheduler名称
* @param schedulerName scheduler名称
*/
public void setSchedulerName(String schedulerName) {
this.schedulerName = schedulerName;
}
/**
* 获取 延迟启动秒数
* @return delayed 延迟启动秒数
*/
public String getDelayed() {
return this.delayed;
}
/**
* 设置 延迟启动秒数
* @param delayed 延迟启动秒数
*/
public void setDelayed(String delayed) {
this.delayed = delayed;
}
/**
* 转换成SchedulerServiceStrategyParameter
* @param object 转换bean
* @return SchedulerServiceStrategyParameter实体类
*/
|
public void translate(Object object) throws UnsupportedTranslateException {
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.