Compare commits

..

583 commits
v1.0 ... master

Author SHA1 Message Date
d1515c2ab2
Fix using delegated config properties from the Core 2023-07-01 20:11:19 +02:00
512a62d75c
Fix remaining test cases for formatting
- Fixed name mentioning test check
- Removed legacy tell raw stuff
- Fixed RPC sections getting combined because the settings weren't updated before checking if they are the same
- Fixed spoiler test assuming and expecting the hover text to be white
#130
2023-06-28 23:56:35 +02:00
b5fd834dc7
Fix chat tests with MockBukkit and fix Paper version
#130
2023-06-27 01:39:35 +02:00
e35e94e87c
Migrate chat formatting to Paper's text component API (#130)
- Also updated the configs to use the interfaces
- Also updated the fun component to use a list config
- The text component change adds Paper as a requirement for this plugin
2023-06-19 00:42:29 +02:00
51cf31713b
Start fixing errors related to player API changes
- The fancy chat API would be useful here, I don't want to update my old code
2023-06-09 01:25:09 +02:00
2242655c41
Merge branch 'hotfix/1.0.1'
# Conflicts:
#	src/main/java/buttondevteam/chat/components/towny/TownyComponent.java
2023-06-07 23:37:10 +02:00
522f29ba58
Update Chroma-Core to v2.0.0 2023-04-26 00:03:18 +02:00
10bf0e98df
Update Towny dependency and replace methods that were removed (#128) 2023-03-13 00:47:40 +01:00
6c1378f370
Update dependencies and fix tellRaw for 1.17+ 2021-12-30 21:19:22 +01:00
56b9296fbb
Merge pull request #126 from TBMCPlugins/dependabot/maven/org.apache.logging.log4j-log4j-core-2.17.0
Bump log4j-core from 2.13.2 to 2.17.0
2021-12-30 16:47:37 +01:00
dependabot[bot]
5c399a08ad
Bump log4j-core from 2.13.2 to 2.17.0
Bumps log4j-core from 2.13.2 to 2.17.0.

---
updated-dependencies:
- dependency-name: org.apache.logging.log4j:log4j-core
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-18 18:20:48 +00:00
724858ac70
Fix tellRaw for 1.16.4/1.16.5 2021-01-18 17:18:35 +01:00
9a10dcd1fc
Fix plugin.yml 2020-10-31 18:24:52 +01:00
dc6df53c96
Improve test coverage, preparations, fixes
Removed an unnnecessary bit of code from ChatFormatter
2020-10-29 20:31:38 +01:00
7646db4487
Fix player data plugin name, Spotbugs fixes
Also set the version
2020-10-28 00:28:15 +01:00
8e9989caee
Convert all configs 2020-10-26 19:56:22 +01:00
77b5a069c5
Merge pull request #123 from TBMCPlugins/dependabot/maven/junit-junit-4.13.1
Bump junit from 4.12 to 4.13.1
2020-10-25 02:00:58 +02:00
c52a6873fe
Exception stuff and player data stuff 2020-10-25 01:18:36 +02:00
c6ba0ec607
Create codeql-analysis.yml 2020-10-13 18:02:45 +02:00
dependabot[bot]
737016bf00
Bump junit from 4.12 to 4.13.1
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-13 15:56:57 +00:00
a63f2bb256
Greentext formatter, doc and stuff 2020-09-06 22:46:24 +02:00
59dbc78b52
Fix #122
It will have to be fixed again at a later date
2020-09-04 03:56:25 +02:00
b483b7df0c
Fix /waitwhat and /me 2020-09-04 03:41:23 +02:00
4d4448fca1
Remove htmlcleaner and fix #117 2020-08-26 22:19:56 +02:00
02423153de
Merge pull request #119 from TBMCPlugins/dependabot/maven/org.apache.logging.log4j-log4j-core-2.13.2
Bump log4j-core from 2.8.1 to 2.13.2
2020-07-27 01:15:05 +02:00
ce4f40c2c4
Fix /u ncolor (#118) 2020-07-25 14:17:11 +02:00
dependabot[bot]
372b2f49b3
Bump log4j-core from 2.8.1 to 2.13.2
Bumps log4j-core from 2.8.1 to 2.13.2.

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-01 18:27:01 +00:00
7448eb7e3a
1.16 updates, fixes 2020-06-27 03:00:08 +02:00
c688ec9243
Finally fix Towny errors for 1.12 - use the intended API everywhere 2020-04-08 01:10:49 +02:00
e4b47efd3f
Fix case when the second section goes further when combining
And added a test for it
2020-04-07 23:08:48 +02:00
43525bd93c
Add missing backslash after "From X" and before "n" 2020-03-20 02:06:07 +01:00
052149bcb7
Add tabcompletes, fix some commands and help texts 2020-03-20 01:26:14 +01:00
5d8ae7fbd0
Command fixes, remove old preprocessor
Fixed command channels
/tpahere message removed
Made /me an actual command
Fixed some help texts
2020-03-15 03:09:00 +01:00
f3ec9e7870
Merge branch 'dev'
# Conflicts:
#	.idea/ButtonChat.iml
2020-03-04 23:11:31 +01:00
0421cc6d16
Small formatter fixes, docs 2020-03-04 23:07:56 +01:00
aad65e0222 Remove 2 TODOs 2020-03-04 10:45:26 +01:00
03b91d2fdb Don't allow sending messages too fast
The player needs to wait the configured amount of milliseconds between messages
#115
2020-03-03 16:13:39 +01:00
661534b92d Update README.md 2020-03-02 12:40:16 +01:00
6af2ad79a7
Remove old loading code, use inherited registerCommand() 2020-02-16 20:28:19 +01:00
f19aa41205
Configure CI build for GitHub Packages
Also fixed a couple issues based on an analysis
Removed debug souts
2020-02-15 00:23:04 +01:00
4952923f9b
Fix all remaining issues with the chat processing
Checking regex formatters first, then string, then range
Fix section combining
24/24
#71
2020-02-13 17:20:17 +01:00
4d0c7c170e
Fix many issues with the chat processing
#71
2020-02-13 00:24:31 +01:00
0dbfaa65a5 Fix remaining compiler errors
The italics test works so far
2020-02-12 19:16:05 +01:00
30ee99d495 Converted formatters to match providers 2020-02-12 12:45:42 +01:00
1dc801575a GH Releases, formatter work, removed old code
TBMCPlugins/ChromaCore#76
2020-02-10 13:46:39 +01:00
0a4cdd01ce
New approach for chat processing
Created different providers for regex, range and string matching
Handling one match at a time per provider

TODO:
Formatters should be executed one by one in declaration order
Add enitre message by default
Loop until all of the providers are finished
Ignore any areas returned by the providers

#71
2020-02-08 01:46:00 +01:00
b452170ff7 Rename 2020-02-04 17:43:35 +01:00
c66b212b0c
Merge pull request #114 from TBMCPlugins/dev
Misc. fixes, chat history config, clickable announcements
2020-02-01 20:13:05 +01:00
2d874d7bc9
Clickable announcements and some fixes
Fixed announcement storage (#112)
Disabled some components by default
Made announcements clickable and copiable (#95)
Fixed /mwiki (#110)
Fixed /u info (#111)
Added test for rainbow chat (#103)
Fixed crash if Dynmap-Towny isn't present
Removed old command annotations
2020-01-31 22:01:29 +01:00
cda2a36da1
Ping sound config, chat history config, lot of descriptions
Moved ping sound configs to the FormatterComponent
Made an option to disable the chat history
Added descriptions for each config option
2020-01-25 03:52:25 +01:00
d5f500aece
Fix Ftask, display error, fix history
Fixed Ftask not being assinged so it couldn't be handled on a new event
Displaying an error to everyone in-game who will see the errored chat message
Fixed message history race condition
#113
2020-01-25 02:14:01 +01:00
2a9bc58157
F i x & clean combining and attempt to fix range conversion
It might do too many sorts but hey
#71
2019-12-15 03:49:32 +01:00
22c7fed75d
F i x remchars, improve combine
Also a newCombine method from yesterday
#71
2019-11-17 03:14:28 +01:00
825e327903
Fix underscore pattern - it was wrong all along
Fix test - in IntelliJ anyways
2019-11-16 01:08:20 +01:00
fd3d3df108
Merge pull request #105 from TBMCPlugins/dev
1.14 support, fixes
2019-10-30 19:35:42 +01:00
c0128831a7
Use parent POM 2019-10-23 02:46:15 +02:00
013287cb47
Update to Java 10/11 2019-10-20 20:53:15 +02:00
cc6c477add
Fixed TownyAnnouncer
It took way too long to figure out how to add an appender that actually takes effect
Also changed Towny dep, it'll likely break Travis builds
2019-10-20 02:32:10 +02:00
a91ee1b842 Registering the formatter component
Only disabling the chat handler if the component is enabled
2019-09-30 15:55:25 +02:00
aa455e373d
Only send the message to the same group
#106
2019-09-30 11:52:32 +02:00
6a16a3a1d5 Actually setting names for the formatters
Also made the name and the pattern mandatory
#85
2019-09-23 13:41:24 +02:00
750b71de65 Created FormatterComponent & formatters can be disabled
It allows disabling chat processing as a whole or formatting
Formatters can be disabled one by one
#85
2019-09-23 13:24:39 +02:00
bd656015bf
Fixes, improved color mode command
Renaming
Fixed TownyAnnouncer once again - but it still doesn't work
Improved color mode (separated "unknown color" and "reset")
Fixed ping sound hiding for nicknames (#90)
2019-09-21 02:21:53 +02:00
fa375c4912 Updated code relying on Towny & updated Lombok version
Towny now uses log4j
Newer Lombok supports Java 11
2019-09-16 15:35:28 +02:00
a964ce6595 Fix Towny dep 2019-09-16 13:39:33 +02:00
4a456d9b1e Fixed 3 issues (hopefully)
Fixed #104
Fixed #101 and also allowing spaces in the action
Fixed #90
2019-09-16 11:49:03 +02:00
a4b7f689c0 Fix Travis 2019-09-02 15:38:04 +02:00
b3939f3c92
Small stuff
Pretty much just renamed the plugin
2019-08-27 03:04:21 +02:00
1275cdafd0
Removed scoreboard that has been there for a long time
PluginMain.java:40
Also made the channel scores unnecessary
As well as the recently introduced dispatchConsoleCommand method
Also probably fixed Towny spy (#100)
2019-08-13 15:02:34 +02:00
f3904a8448
tellRaw continue
Didn't commit it earlier today, but I'm not gonna work on it now
2019-08-13 01:19:55 +02:00
415e61a401
isChatOn fix, tellRaw start 2019-08-12 02:50:18 +02:00
7b2ecdbf7b
Renamed config methods to match the keys 2019-08-07 18:28:47 +02:00
4956837e5d
Not processing messages when nobody is online 2019-07-22 22:37:23 +02:00
3ad2346990
Finally fixed #99
Totally didn't forget about it
2019-07-10 15:26:46 +02:00
8907d5308f
1.14 prep & chat formatter organizing
(1.14 prep is older code)
2019-06-30 22:04:33 +02:00
bbe9a8c146
Added snap command from master 2019-06-15 00:40:48 +02:00
80e45aa1a9
Added snap command 2019-04-24 23:57:52 +02:00
c25097b525
Merge pull request #98 from TBMCPlugins/dev
More components, broadcasts
2019-03-17 02:28:21 +01:00
049ad55168
Town/nation color fixes, reload command 2019-03-16 14:33:03 +01:00
c7f04b8731
Converted all of the commands
Moved the announcer commands into one class
2019-03-16 03:07:33 +01:00
073346eb7f
/u c sender changed to player 2019-03-14 16:42:32 +01:00
5b5252382e Converted, moved and deleted some commands
Converted & noved:
/u opme
/yeehaw
/u c

Deleted:
/u admin playerinfo
/u admin updateplugin

Also made the FunComponent more configurable
Also removed old command registration, so some commands will stop working
#85
2019-03-11 12:36:19 +01:00
e510667215
Rename, fix, nc toggle
Renamed plugin
Fixed duplicate chat handling (DC->MC)
Implemented nation color toggle
2019-03-09 23:02:46 +01:00
ae49777007
Made appendtext commands fully configurable 2019-03-08 22:22:12 +01:00
8ff45ad676
Some fixes
Crash on player join without Towny fixed
2019-03-02 19:02:01 +01:00
4744f2edf9
Supporting clean installs
And other fixes
Also moved the Votifier reward to the core
Checking if Towny is present (only a soft-depend now)
2019-03-01 17:58:40 +01:00
f7c1106d1c Replaced (almost) all broadcasts 2019-02-27 16:41:49 +01:00
40a1739951 Moved /un... to its component 2019-02-27 13:48:36 +01:00
c5e33a93ba Moved chat-only stuff, F top, append text start
#85
2019-02-20 16:48:08 +01:00
26b44fbfe1 Moved all /unlol and F stuff
#85
2019-02-20 15:23:07 +01:00
36655dfd84 Adding project file and moving /unlol
Also fixed Vault dep
2019-02-20 13:41:53 +01:00
df7f8bca5e
Town color error fix, applying changes 2019-02-12 22:28:42 +01:00
e2a6afd16a
Added spoiler support 2019-02-01 17:53:54 +01:00
21bf41db2b
Merge pull request #97 from TBMCPlugins/dev
Added /press command, Dynmap nation color support
2019-02-01 17:08:21 +01:00
185b0df8e0
A change and a fix
Say the nation name which already uses the color
History command help text fix
2019-01-30 23:33:16 +01:00
f12912c735
Added /press command, Dynmap NC support
#40
Both tested and work
2019-01-30 21:16:02 +01:00
d0e4447126
Merge pull request #96 from TBMCPlugins/dev
Towny event broadcasting to Discord and masked links
2019-01-20 22:39:53 +01:00
3a29010042
Fixed cast error, NPE, masked links
Fixed config cast error
Fixed mcchat NPE
Implemented masked links
Added a test for it
2019-01-19 20:26:39 +01:00
0802de4b6f
TC/NC & Removed old config stuff
Moved town/nation colors into their component
Removed save command that was apparently there since 2015
It still loads the town/nation colors from the old config if needed
Notification sound/pitch were the last config options to be converted over
#85
2019-01-17 22:23:04 +01:00
3f387a9775
C o m p o n e n t s
FlairComponent
AnnouncerComponent
TownyComponent
Some fixes
Removed old fields and JarUtils
#85
#84
#4
2019-01-13 01:40:54 +01:00
25ce2a4c9f
API changes 2019-01-12 01:24:31 +01:00
8ccf3ee9d7
Guess what, configs 2019-01-10 01:46:59 +01:00
bfe7d48760
Towny logger works
TBMCPlugins/DiscordPlugin#81
2019-01-09 18:57:21 +01:00
be29caa904
Added handler for Towny logger
Listening for Towny events and sending it to our system
2019-01-04 01:11:15 +01:00
2b621adefb
Merge pull request #93 from TBMCPlugins/dev
Fixes (/u ncolor), not allowing two of the same town colors, not broadcasting announcements if nobody is online
2019-01-03 21:43:21 +01:00
aed7864a15
Fix nickname regex bug
The previous implementation didn't consider tbe case when the last player in the list doesn't have a nickname, leaving an empty "always match" part which messed up the formatting
@FigyTuna
Also added editorconfig for GitHub formatting
2019-01-02 23:30:46 +01:00
720740dea3
Fixed URL processing (&, #)
New Years Commit
2019-01-01 03:28:46 +01:00
99a8c1b020
Fixed nicknames if only 1 player is on
Also added a town colors component class
2018-12-28 00:55:32 +01:00
12072f3106
9 less lines for what works better
Storing the entries per-group which also means there's no need to loop through each entry - and it won't limit it globally
2018-12-27 14:16:40 +01:00
1081f3cf9d
Chat history works! Also fixed a lot
Actually registered the join/leave listener, fixing town colors and nickname mentioning as well
Chat history is finished, it only shows messages that the sender has access to
#82
2018-12-27 00:02:47 +01:00
f8539a0392
Adding chat history command
#82
2018-12-26 03:03:51 +01:00
cf8af73ed0
No players, no announcements
Not broadcasting announcements if nobody is online (mainly because of Discord)
2018-12-24 00:14:38 +01:00
fd72e2de91
No filteranderrormsg 2018-12-18 00:52:56 +01:00
dedfbacda6
NColor fix and only one TC/NC
NColor fixed
Only allowing one of a color combination
Only allowing one of each nation color (except the default)
2018-12-16 19:16:05 +01:00
6da19877b8
CI build branch fix: Origins
From now on, the TRAVIS_BRANCH variable must be defined, either to master if the other projects (ButtonCore) are built locally, or the correct branch if not
2018-11-22 00:59:22 +01:00
71aeafadda
Fix off-by-one error 2018-11-04 22:03:54 +01:00
304f5c562d
Merge pull request #92 from TBMCPlugins/dev
Nation color, /tableflip fix, improvements and other fixes
2018-11-04 01:47:20 +01:00
df6e76086b
Treating the RP channel as global 2018-11-01 01:24:01 +01:00
241992571e
Nation color works!
Getting Essentials on enable
Both nation and town colors are white by default
2018-10-28 23:35:20 +01:00
58d8d1276f
Yeehaw fix & applying changes 2018-10-25 23:51:39 +02:00
3124d41f54
AppendText, F and other user fixes
#88
TBMCPlugins/DiscordPlugin#61
2018-10-25 14:13:56 +02:00
e6ada0b2d0
Probably fixed a Discord chat issue
DiscordPlugin#61
2018-10-24 00:08:03 +02:00
775789a451
More work on nation colors
Needs testing
2018-10-22 00:53:52 +02:00
0ac78c9cb2
Some work on nation colors 2018-10-21 19:45:11 +02:00
83c99df895
Adding support for nation color (WIP)
Also various fixes
Got rid of a bunch of warnings
2018-10-11 13:15:03 +02:00
c080a857fd
Merge pull request #87 from TBMCPlugins/dev
Fixed /shrug, name mentioning and other formatting issues
2018-08-14 00:57:22 +02:00
45b273e036
Fixed name mentions in URLs 2018-08-12 23:07:03 +02:00
c5cae54aea
FIXED /SHRUG!
https://giphy.com/gifs/marvel-guardians-of-the-galaxy-2-3o7btZCvEwsCtTaS0E
3 failing and 15 passing tests
#71
Also added combining parts
2018-08-12 21:44:42 +02:00
7006f178b9
Implemented excluding, added tests
Added failing tests as well as passing tests
2018-08-10 13:46:47 +02:00
24c9e2d494
Name mention testing, excluding
Still need to make it actually exclude the names
2018-08-08 21:50:44 +02:00
62caf31727
Added more failing tests
And slightly fixed shrug test
2018-08-06 22:28:51 +02:00
44488a78ad
Merge pull request #83 from TBMCPlugins/dev
Fixed chat formatting and Discord message hover info in MC
2018-07-20 14:22:12 +02:00
4f2abe41b8
F I X E D F O R M A T T I N G
Except /shrug
#71
Also added strikethrough
2018-07-17 18:29:55 +02:00
e6ac18e0c7
Fixed hover info for Discord 2018-07-17 17:06:42 +02:00
01562bf769
Using the CG object on chat
This means user data will be available (again) if talking from Discord, for example.
2018-07-15 02:22:40 +02:00
050fd88560
Added API changes 2018-07-12 23:27:17 +02:00
f2a7a10ef7
Merge pull request #81 from TBMCPlugins/dev
Made chatting always disable AFK mode
2018-06-30 02:34:45 +02:00
ab5c9e3ea6
A F K - chat counts as activity 2018-06-28 20:09:50 +02:00
bf1a5562a0
Fix update dir 2018-06-15 20:03:23 +02:00
79d0d06044
Merge pull request #80 from TBMCPlugins/dev
Update 2 - Bugfixes (town colors) & fromcmd
2018-06-15 18:43:26 +02:00
b174b8969e
Bugfixes (town colors) & fromcmd
Fromcmd
#78
#79
#75
Nickname tabcompletion
Handling town rename/delete for town colors
2018-06-12 18:29:55 +02:00
68de2f36cf
Fixed respect, town colors etc.
Fixed respect display to 2 decimals
(Fixed a "critical" bug in... 25 days) #73
Fixed town colors hopefully (#74)
Fixed /u ncolor requiring the ~
Added support for colons for ncolor

Yesterday I already woke up by this time and I'm still not sleeping now
2018-05-21 03:55:41 +02:00
ef2328e126
Re-added nickname map... Fixes 2018-05-18 01:32:05 +02:00
71242cc0ac
Merge branch 'dev'
# Conflicts:
#	src/main/java/buttondevteam/chat/listener/PlayerListener.java
2018-05-16 23:03:42 +02:00
6d3d24ecbf
Added support for ch IDs field 2018-05-16 22:56:59 +02:00
0c768b95e8
Removed nickname map
Huh

Squashed with a test commit
2018-05-15 01:07:09 +02:00
4a7d7379b0
Hotfix & /ftop 2018-04-24 21:31:13 +02:00
6202e30522
Merge pull request #72 from TBMCPlugins/dev
Chat fixes, town color fixes, some features
2018-04-24 12:14:51 +02:00
991ca23918
Added patron badges & changed wait what
And fixed Votifier repo
2018-04-22 23:13:24 +02:00
2de3f1f6e7
Changing nicknames instead of display names
Essentials dependency fixed
2018-04-20 23:37:41 +02:00
e5053a0483
Fixes and more helpful error messages 2018-04-18 22:44:31 +02:00
4006cdad58
Buunch of fixes (TownColor)
- Banned the color black
- Made the color list colored (when using an invalid color)
- Finished displayname-refactor (hopefully)
- /u ncolor will now show how your name looks
- Using the display name in the Tab list
- Nickname handling fixed in NColor
- Smaller fixes
Testing needed
2018-04-16 21:51:19 +02:00
1c0c29ae96
Fixes, WIP (TownColor) 2018-04-09 00:46:42 +02:00
4340a50789
Some things
Some fixes and @ someone are days old.
The FTopComomand is weeks old.
2018-04-06 17:01:32 +02:00
91e44c20c2 Bugs were fixed, some of them anyways 2017-11-27 23:32:01 +01:00
f671b6e9d6 String index out of range: -9 2017-11-26 23:22:17 +01:00
029a7f1deb ChatFormat fixes (RC) 2017-11-26 00:29:10 +01:00
35ccf22a55 Added handling if a class... doesn't exist 2017-11-23 23:51:14 +01:00
840b522a98 It was my greatest enemy, *parenthesis*
...or the lack of them anyways:
Finally found what was causing the exceptions
2017-11-23 21:35:14 +01:00
5a217fcb70 Added an important null check 2017-11-04 19:59:08 +01:00
c129e5b18b Fixed Spigot versions 2017-11-04 16:57:41 +01:00
b4de61adf8 Merge branch 'dev' 2017-11-04 16:40:30 +01:00
ae3c05c14a /u ncolor works! 2017-11-04 16:35:37 +01:00
9057ab9f15 Fix 2017-11-04 02:04:34 +01:00
cee69dc55b Made /u ncolor, needs further testing 2017-11-01 22:55:34 +01:00
06ea519987 Inst. update on Dynmap, cmd for mayors, fix
Well, update every ~5 mins on Dynmap, as DT updates
Command for setting town color count added too
2017-10-01 20:07:15 +02:00
b5e8e0f93c *Hacked* town colors into Dynmap-Towny 2017-10-01 01:27:14 +02:00
9abcde610e Added town colors to chat (still need for Dynmap) 2017-09-24 02:37:27 +02:00
e0459fa36f Removed check at tabcomplete because it errored once 2017-09-09 22:03:45 +02:00
ee1430036c Merge pull request #70 from TBMCPlugins/dev
Announcement cmds fixed, nicknames update for mentions, Towny spy fixed, added RP channel, ChatRooms implemented
2017-08-28 18:13:43 +02:00
7174a97728 Fixes, implemented ChatRooms, less code for preprocess 2017-08-28 15:23:06 +02:00
2ab6a5f4eb Nickname impr., Towny spy, RP channel
- Added nickname cache update on nick change for mentions
- Added support for Towny spy (again)
- Removed RPMode and added RP channel
2017-08-27 23:35:46 +02:00
91c22e650b Fixed ann cmds, chatformat Lombok, testing fixing
Fixed announce commands
Using Lombok for ChatFormat
In the process of fixing the tests
Plus #52, #53
2017-08-25 00:56:47 +02:00
d0a990e0f1 Fixed channel scores for Discord->MC 2017-08-23 02:29:11 +02:00
1d1b3453b3 Added support for /ignore, improved unlols 2017-08-22 01:37:54 +02:00
2f83a90553 Added /lenny to plugin.yml and fixed an NPE
Fixed NPE for non-players trying to chat
2017-08-18 03:04:13 +02:00
9ab875f73b Merge pull request #69 from TBMCPlugins/dev
No longer sending messages to "commands only" mode players, added /lenny, fixes related to testing
2017-08-17 18:12:56 +02:00
16acba643f Added 3 chars 2017-08-17 17:49:15 +02:00
51c3e1dec6 Added /lenny and made tests optional + a fix 2017-08-17 17:31:17 +02:00
0de469e514 No longer sending messages to those who disabled it 2017-08-08 15:08:43 +02:00
437d9e8f98 Removed RC messages, fixed URLs probably
#63
Added URL test
Smaller refactors
2017-08-05 01:23:37 +02:00
1c32dbd949 Fixed the fix 2017-08-03 23:52:41 +02:00
107a60eb2e Fixed chat channel MC scores 2017-08-03 22:24:56 +02:00
5e7da1e89a Alright then 2017-07-19 22:56:35 +02:00
bae49352ef Hopefully fixed the SerializationException 2017-07-19 22:50:57 +02:00
2aa0443286 Added RPC support & fixed channels in MC!
Probably
Also did some security-kind of fixing and some refactoring
2017-07-19 21:25:53 +02:00
55053d635e Merge pull request #67 from TBMCPlugins/dev
Formatting fixes (and bugs), chat debug and tests improved, fixed F NPE, plugin name list made async
2017-07-04 18:27:07 +02:00
39ef366c20 Removed test and some dependencies
A few days ago
2017-07-04 00:01:01 +02:00
2b48aba75e Fixed F NPE a whiile ago & fixed now
getOrDefault, then get
2017-06-30 18:08:24 +02:00
4b55c76fd5 Plugin updater refactor, made async 2017-06-23 19:33:52 +02:00
3e0a49659d Separated tests using a custom test runner
Runs: 6/6 Errors: 0 Faliures: 4
2017-06-23 16:49:57 +02:00
2c631b28bc Update .travis.yml 2017-06-18 21:34:53 +02:00
ad3d3ecaf9 Probably improvied chat stuff a bit
Yesterday
2017-06-18 10:38:44 +02:00
6ee8ca0f4c Slowly, slowly progressing 2017-06-09 19:12:04 +02:00
9d7b244a74 Progressing with formatting (hopefully) 2017-06-09 18:23:41 +02:00
c078a292ec Improved debug messages
It looks like the range part works well now
2017-06-09 13:34:23 +02:00
12b1a45558 Progressing with processing 2017-06-09 12:28:52 +02:00
bcd6d3f194 Removed RemCharPos, wasn't used
It was only used for escaping before
2017-06-08 23:37:25 +02:00
d4c016b495 Merge pull request #66 from TBMCPlugins/dev
Less error messages, channel and command changes applied
2017-05-15 02:38:32 +02:00
3e1df267cf Reduced errors and CMDS WORK - EH 2017-05-14 01:16:54 +02:00
28aeb35573 Fixed channels a lot
Made Console be able to send messages
2017-05-07 01:09:39 +02:00
07fccda8d3 Chat channels probably done, needs testing 2017-05-06 19:55:04 +02:00
9e1bd49cd0 Moved and improved Channel stuff and removed old stuff
Removed tons of lines
Also reduced unlol effect duration a few days ago, commiting now
2017-04-30 00:33:57 +02:00
8f69e40d8b Removed http error post and continued cmds 2017-04-28 16:00:05 +02:00
db37482134 Started converting command classes 2017-04-23 02:13:51 +02:00
7751defc9f Fixed NPE 2017-04-15 20:15:15 +02:00
5da1083067 Merge pull request #62 from TBMCPlugins/dev
Added /waitwhat, applied userdata changes, added format test, progressed with formatting
2017-04-15 13:58:12 +02:00
a7a677d85a Disabled some tests to release now 2017-04-15 13:38:42 +02:00
ec5c90ecc8 Fixed bold formatting, other fixes
JUnit is awesome
Diffing the expected and actual result in a small fraction of the time
needed to load the server
2017-04-15 01:45:30 +02:00
758332faf6 Segmented ChatProcessing and added test! 2017-04-14 22:43:37 +02:00
441e9a4eaf Added some comments 2017-04-13 23:23:16 +02:00
0da4a543e5 Small fixes 2017-04-11 21:11:07 +02:00
fa95891a6a Updated ButtonChat to the newer system 2017-04-02 00:01:49 +02:00
a36c6b564b Applied changes 2017-01-02 01:19:38 +01:00
d13dfc3eb2 Added /waitwhat or /ww 2017-01-02 00:03:56 +01:00
c6031a6f11 Added an... important bit 2016-12-31 00:16:00 +01:00
3cd1707182 Merge pull request #60 from TBMCPlugins/dev
Mostly fixed chat formatting
2016-12-30 22:54:02 +01:00
d0e038cdd3 Added #55 2016-12-30 22:11:26 +01:00
e8fa82d10d Merge pull request #59 from TBMCPlugins/chatformat
Fixed chat formatting - Mostly ¯\_(ツ)_/¯
2016-12-30 22:05:01 +01:00
7de0ecc87d Fixed small bug - SHRUG WORKS 2016-12-30 21:50:53 +01:00
2594721152 Fixes! Escape logic again...
- Made the escape chars disappear
- Fixed empty nickname list matching empty strings
2016-12-30 21:22:34 +01:00
0f74ad4cb1 Fixed escape logic even more and readded combine 2016-12-30 19:33:23 +01:00
eba73d6db4 Probably fixed escape logic 2016-12-28 01:12:10 +01:00
81b188f338 Merge branch 'dev' into chatformat 2016-12-27 22:51:28 +01:00
94252e446d Progressing... Slowly... 2016-12-27 22:42:21 +01:00
dc9bcd2cfd Made more commands show in /u help (#57) 2016-12-24 22:44:36 +01:00
1fe200cf3f Added extra channel data for console 2016-12-23 23:14:42 +01:00
5e20689dc1 Made broadcasts and Fs better
- Made *many* messages sent to each player a broadcast message instead
- Removed FCount and PressedF, added the Fs list instead
- Added support for *all* CommandSenders for F
- Inlined PluginMain.GetPlayers()
2016-12-20 22:17:47 +01:00
3ab97276f6 Finished IsRange 2016-12-19 22:33:11 +01:00
4311a567c5 Removed JAR finally... 2016-12-19 22:25:01 +01:00
1bb3ddb0ee Fixed the Legendosh bug again
Fixed NPE at getFlairState()
2016-12-19 20:25:29 +01:00
f39ed23699 Started formatter and escape logic 2016-12-18 13:33:04 +01:00
15ece1a3dc Made custom chat event cancellable 2016-12-18 12:57:57 +01:00
888086f427 Added fallback if chat processing fails 2016-12-18 00:42:45 +01:00
BuildTools
596a4e422e fixing my fix again, more typos - ChatProcessing 2016-12-17 15:26:01 -05:00
BuildTools
e2b33f5342 fixing my attempted fix, forgot semicolon, ChatProcessing 2016-12-17 15:19:57 -05:00
BuildTools
63f7106000 attempted fix, ChatProcessing line 125-136
I believe the previous code was creating unbalanced parenthesis
2016-12-17 15:03:53 -05:00
da3eacc2e1 Moved javassist to ButtonCore 2016-12-17 12:48:47 +01:00
08640f404d Started working on the chat formatter 2016-12-17 00:37:04 +01:00
a3b3af859a Properly added a bug as a feature
Wth did I just do before - Anyways, fixed null nicknames
2016-12-16 21:25:13 +01:00
845f3e1f16 Added a workaround for the issue...
Just realized that the match itself is null
2016-12-16 21:16:22 +01:00
a09a30d460 Let's do some more live testing 2016-12-16 20:57:57 +01:00
6d75e9bd9e Fixed help text 2016-12-16 19:25:50 +01:00
0a4ab5a46e Fixed fix of NPE 2016-12-16 14:18:43 +01:00
a058990075 Fixed usernames NPE 2016-12-16 14:17:54 +01:00
a2ad97faec Probably fixed flair cheater NPE 2016-12-16 14:10:40 +01:00
64529eef73 Added support for branches in UpdatePlugin
https://github.com/TBMCPlugins/ButtonCore/issues/23
lmao
2016-12-11 00:02:51 +01:00
9c06e22ca7 Made the chat plugin less essential and fixed /u help <cmd>
- CommandCaller moved to ButtonCore
- Now only cancelling the Bukkit chat event if the custom event ran
without an error
2016-12-09 18:10:30 +01:00
alisolarflare
24d04f04c8 Added UTF-8 as default encoding 2016-12-08 16:40:08 -05:00
9ec35cbfb3 Changed error message... 2016-12-08 22:23:06 +01:00
8e53762d3e Probably fixed internal error on /u 2016-12-08 22:18:32 +01:00
55df5b5ede Made integer data optional
https://github.com/TBMCPlugins/DiscordPlugin/issues/19
2016-12-08 21:36:56 +01:00
3aacd07691 Finally implemented #41 and an event
YEEHAW
Oh, and smaller /mwiki changes
2016-12-07 21:15:09 +01:00
bd55c580c9 Fixed Discord indicator
https://github.com/TBMCPlugins/DiscordPlugin/issues/15
2016-12-07 17:53:05 +01:00
6d38b5b9f1 Added sender indicator for chat msgs
https://github.com/TBMCPlugins/DiscordPlugin/issues/12
2016-12-04 20:16:53 +01:00
57f15694ad Applied changes 2016-12-04 20:07:02 +01:00
44984d8987 Smaller fixes 2016-12-04 19:06:18 +01:00
8c08370220 Refreshed error handling, removed getlastereror 2016-12-03 19:53:58 +01:00
1af101c31e Made the info command not player-only 2016-12-03 12:47:23 +01:00
d481152eb0 Fixed the Legendosh bug 2016-11-29 20:55:25 +01:00
773b142e80 (Re)Added setCancelled for chat 2016-11-26 16:29:20 +01:00
39d932bf77 Added support for the chat event 2016-11-25 19:46:23 +01:00
9857bc5bd5 Removed Minigames stuff 2016-11-20 22:29:31 +01:00
f83f8f88b7 Fixed player info 2016-11-19 20:29:42 +01:00
a608998f59 Fixed inconsistent lowercase setting 2016-11-19 19:20:49 +01:00
80d424d6f8 Added some details to internal error msg 2016-11-19 18:58:06 +01:00
98b58dd4b9 Added handling of no top level command 2016-11-18 20:10:48 +01:00
a87c71f37b Moved everything for Channel.java 2016-11-15 22:34:07 +01:00
5ec39c3581 Fixed flair in onGetInfo, improved channels 2016-11-14 17:58:09 +01:00
e356a401e2 Applied plugin updater changes 2016-11-12 21:05:08 +01:00
c534a45b73 Fixed code for NPE handling with NPE 2016-11-12 01:12:42 +01:00
dcc955a816 Fixed NPE with an NPE (#51)
From my phone. :P Also it's a more descriptive NPE.
2016-11-09 12:30:11 +01:00
795eacf38d Cleaned PlayerListener a little bit 2016-11-04 21:33:28 +01:00
cffd2607aa Moving PlayerListener 2016-11-04 18:59:03 +01:00
9adf449ef2 Fixed onCommand... 2016-11-03 22:03:12 +01:00
34a309b49f Forgot that continue 2016-11-03 20:03:34 +01:00
9a8baf5653 Added some stuff 2016-11-03 19:57:07 +01:00
cd490e5769 Made command paths a bit more logical 2016-11-03 18:22:57 +01:00
398912353b Minor fix and additon 2016-11-03 16:28:16 +01:00
d2a302061f Using the exception listener here as well 2016-11-02 18:39:16 +01:00
72eec3e240 Fixed references 2016-11-02 18:19:44 +01:00
711e223f2a Added userinfo support 2016-11-01 22:23:34 +01:00
3c46385c80 Applied ButtonLib changes
IT WORKS!
2016-10-30 22:58:35 +01:00
900f815e26 Added enum data handling
Also committed an older fix
2016-10-30 21:47:42 +01:00
5b63ed08ed Moved GetSubCommands() 2016-10-29 22:11:33 +02:00
fe51c015db Removed reload command and fixed errors 2016-10-29 19:47:13 +02:00
c810053558 New player data handling added (WIP) 2016-10-29 14:11:29 +02:00
caa63f7912 Moved some command stuff
It took a while
2016-10-28 21:42:34 +02:00
4d5c3db239 Fixed typo 2016-10-26 22:35:28 +02:00
ed858502f4 Fixed the no nick case and other stuff 2016-10-26 18:41:06 +02:00
0883739861 Fixed errors 2016-10-24 20:45:16 +02:00
858a9704f3 Updated references to the Core 2016-10-23 02:24:02 +02:00
b1fe758003 Did #48 and added a note
- Cleaned PlayerListener (#48)
- Added a note for reload command
2016-10-18 20:21:02 +02:00
854ba613b5 Made plugin updating async 2016-10-14 22:44:42 +02:00
596c929ace Fixes 2016-10-06 20:16:32 +02:00
60d35d8eae Cleaned some old stuff and did #47 2016-10-04 22:12:24 +02:00
a173cdefb2 Added RemCharPos support 2016-10-02 12:14:54 +02:00
c4e22a779e Fixed #46! The char remove still WIP 2016-10-01 19:10:50 +02:00
798e5903de Added #49 2016-10-01 13:44:20 +02:00
398ec7ce25 Fixed /u name and such 2016-09-30 13:22:39 +02:00
6d9037592a Partially added #49 2016-09-25 22:26:16 +02:00
9e1b1152c1 Hopefully about to fix #46 2016-09-25 21:54:22 +02:00
85a1defb6a #46 is harder than I thought 2016-09-24 19:00:37 +02:00
0e54ce1fed Formatted debug message 2016-09-24 18:28:08 +02:00
9edc49a4a0 Almost fixed #46 2016-09-24 18:20:12 +02:00
bda72749cd Probably fixed #46 2016-09-24 17:31:55 +02:00
4a454da723 Added TODO 2016-09-24 13:27:58 +02:00
cb91125028 Started fixing #46 2016-09-24 13:18:09 +02:00
78a0a12d26 Fixed pom.xml 2016-09-17 00:35:38 +02:00
eb38613598 Renamed project 2016-09-16 21:48:44 +02:00
98aab1c923 Update README.md 2016-09-11 18:31:16 +02:00
2d9fbc7ce4 Converted Javassist 2016-09-11 17:53:55 +02:00
41ba4353d2 Fixed JAR including 2016-09-11 17:48:23 +02:00
91ea0742f5 Moved files 2016-09-11 17:35:39 +02:00
b88df7672c Added resource plugin... 2016-09-11 15:29:48 +02:00
5c54998543 Added resource tag here too 2016-09-11 15:26:06 +02:00
0bdd2e46f3 Fixed includes 2016-09-11 14:22:23 +02:00
4cfa77b7f4 Removed some old code, Maven stuff
- Removed remaining stuff of CreativeGlobalMechanic
- Removed external JARs and put Maven shade for them
- Added all dependencies to pom.xml
2016-09-11 14:16:35 +02:00
c8649cb5b0 Switched to Gson - MVN WORKS! 2016-09-10 21:05:32 +02:00
9542523ab8 Trying jitpack.io - Missing artifact 2016-09-10 00:56:25 +02:00
8339a209f8 Removed Minigames mechanic and spent hours to push compiled JARs 2016-09-10 00:28:36 +02:00
00e336c4b2 Updated flair thread, added Mvn repo stuff 2016-09-09 21:44:51 +02:00
84ba92a23b Uploaded JAR 2016-09-08 21:11:16 +02:00
10bc057187 Removed some (reeally) old TODOs and such 2016-09-08 21:00:50 +02:00
dc7913ca14 Fixed formatting! 2016-09-08 19:44:03 +02:00
6648bc6901 FIXED tellraw json serializing - mostly 2016-09-08 18:27:10 +02:00
e83e4724f7 Implemented #42
Players should be already allowed without flairs
2016-09-08 16:51:11 +02:00
4031d9df46 Updated that ... plugin.yml 2016-09-08 16:31:13 +02:00
050b100819 Put formatter stuff in it's package 2016-09-08 16:27:45 +02:00
84f87af748 Put formatter stuff in it's package 2016-09-08 16:27:39 +02:00
abbad506cc Renamed package... 2016-09-08 16:23:44 +02:00
842df1c85a Renamed package... 2016-09-08 16:23:30 +02:00
bd8dbe020b Added #44... And some fixes 2016-09-05 20:37:08 +02:00
3dc6f08a66 Probably fixed name mentioning 2016-09-05 16:46:38 +02:00
f34deb7abc Probably fixed name mentioning 2016-09-05 16:46:38 +02:00
fe974035aa Upload JAR 2016-09-04 21:13:54 +02:00
5cdbe61166 FIXED #39! Mostly. 2016-09-04 21:07:09 +02:00
9d18604c25 Partially FIXED #39 2016-09-04 19:07:03 +02:00
d68241eb42 Fixed things 2016-09-04 00:16:46 +02:00
247228faee Added things on image 2016-09-04 00:04:17 +02:00
7988c928ff Added image for planning 2016-09-04 00:03:17 +02:00
ce75413e2c Removed old code 2016-09-01 18:48:24 +02:00
725067dc93 Uploading reference updates 2016-08-22 19:39:31 +02:00
69d0a3f0d7 Updated JAR 2016-08-22 16:46:55 +02:00
2c08cab6b5 Fixed constantly loading players for flair update 2016-08-22 16:38:20 +02:00
f4eb32c35f Fixes 2016-08-22 16:17:09 +02:00
994af42e54 Fixed updater and some other older changes 2016-08-22 14:29:34 +02:00
a00ca2611e Updater and org.json moved to the Core 2016-08-14 23:42:42 +02:00
6d883ddbef Made some changes
- Made command registration for other plugins more flexible
- Using logger instead of sysout
- Started moving plugin updater to the core
2016-08-14 14:41:54 +02:00
8e091beb33 Added help text, and such 2016-07-29 21:22:18 +02:00
1d9b49f4bd Fixed things, added project file 2016-07-29 18:50:00 +02:00
381955ef1a Various fixes 2016-07-17 02:26:53 +02:00
13ec4e43ad Renamed to ChatPlayer 2016-07-16 23:55:36 +02:00
fc2267d43f Renamed TBMCPlayer 2016-07-16 23:55:25 +02:00
f1d0da594a Renamed package 2016-07-05 00:29:12 +02:00
07b5541d8d Fixed cheater auto-flair and renamed package 2016-07-05 00:28:50 +02:00
7c1f79e512 Merge branch 'master' of https://github.com/TBMCPlugins/thebuttonmcchat 2016-07-01 23:47:10 +02:00
ccdb53023e Fixes and preparing to move things 2016-07-01 23:32:41 +02:00
61f93ecd15 Added things and TODOs 2016-07-01 17:12:02 +02:00
Juhász Család
f168931496 Added things and TODOs 2016-07-01 17:12:02 +02:00
fb869c7662 Added API with documentation, renamed player class 2016-07-01 16:54:21 +02:00
b6bf563b4b Update README.md 2016-07-01 15:56:26 +02:00
dfdd6eec87 Fixed error when nobody is online 2016-07-01 00:31:10 +02:00
1e95f3773a Did #29, probably #38 and #26 over the past few commits. 2016-07-01 00:16:14 +02:00
7a39a0bc7d Added debug mode and fixes. 2016-07-01 00:03:30 +02:00
12963b58cb Getting closer. Also added toString methods. 2016-06-30 22:24:47 +02:00
5442b41528 Chat works again! It's still kind of buggy though. 2016-06-30 00:10:46 +02:00
1543a11049 Chat formatting still WIP... 2016-06-29 14:36:25 +02:00
4c8f6f024e Making progress... 2016-06-29 00:45:04 +02:00
578d37c777 Still formatting messages... 2016-06-28 13:27:48 +02:00
4ca1c6a2d7 Idk 2016-06-27 19:56:12 +02:00
c6ffdf1868 Message formatting still WIP 2016-06-27 00:36:36 +02:00
ea5e7ae87d Chat formatter WIP 2016-06-25 21:05:00 +02:00
18ae134294 Changed rainbow mode to tellraw format and fixed /mwiki bugs 2016-06-25 14:33:25 +02:00
7d78246672 Plugin update 2016-06-25 13:09:21 +02:00
88557f85cb Numerous fixes related to reloading the plugin, flairs and yeehaws 2016-06-25 12:51:04 +02:00
ffa7c3f850 Code cleanup 2016-06-25 10:59:42 +02:00
cc574c3450 Command system finished with #21! 2016-06-25 10:48:24 +02:00
718f43e303 The command system works! Kinda... 2016-06-25 02:02:38 +02:00
47315bbdaf Command system under construction 2016-06-24 19:32:34 +02:00
2d7447a46f New command system is getting ready 2016-06-24 19:02:45 +02:00
b312f2358e Fixed things 2016-06-24 01:38:17 +02:00
6889f8ed87 Fixed #33 and minor bugs 2016-06-23 12:51:53 +02:00
76655a2c91 Fixed things and added files... 2016-06-23 12:42:22 +02:00
c96a83af07 #21 still WIP 2016-06-23 12:05:29 +02:00
47a73ac24d Rename continues 2016-06-23 01:44:21 +02:00
71bd4e6606 Change project and repo name 2016-06-23 01:38:35 +02:00
838fa9fe03 Prev commit fixed #34, #21 is still WIP 2016-06-23 01:09:49 +02:00
bce31de137 Command refactoring is in progress... 2016-06-23 00:08:39 +02:00
da87a1293e Possible fix for #30, still needs testing 2016-06-22 13:03:38 +02:00
2d46c3bc20 Added #28, fixed #30 and #31 2016-06-22 01:16:22 +02:00
669c5aa616 Probably fixed errors on teleporting 2016-05-13 12:31:27 +02:00
c1f0ec8bf0 Fixed auth control 2016-05-13 12:27:50 +02:00
1220c835cd Update README.md 2016-05-10 21:43:06 +02:00
14712d31d1 Fixed things related to auto-logins 2016-05-07 18:15:06 +02:00
9e75f54865 Fixed Markdown condition and added JAR 2016-05-07 14:28:05 +02:00
Sciguymjm
4dc588fcf7 Added basic markdown support 2016-05-06 14:52:37 -04:00
e712a525ce Merge branch 'master' of https://github.com/NorbiPeti/thebuttonautoflairmc 2016-05-05 21:56:40 +02:00
14837e1d80 Encoding stuff 2016-05-05 21:55:21 +02:00
9c08124716 Update README.md 2016-04-28 22:39:07 +02:00
d79b0dd687 Added an automatic fix for the (0s) problem 2016-04-28 22:19:11 +02:00
c8bb3a4ec7 Fixed not Tableflip. Probably. 2016-04-28 21:17:48 +02:00
1897412d0b Fixed Tableflip. Probably. 2016-04-28 21:13:16 +02:00
b13c62147a Fixed plugin.yml 2016-04-28 16:44:26 +02:00
99196b7d31 Fixed new players having (0s) flair 2016-04-25 22:14:14 +02:00
7eaf6178d9 Renamed package 2016-04-25 22:03:39 +02:00
f9363a7c69 Added none to flair setting 2016-04-25 14:35:43 +02:00
daa341ff7d Fixed stuff and removed support for offline players because #19 2016-04-24 20:12:48 +02:00
7b3edfd0cf Uploaded JAR... 2016-04-24 19:56:01 +02:00
f71904c522 Added another way to set non-presser or can't press flairs 2016-04-24 19:53:49 +02:00
b39a2888d5 Added #17 and fixed stuff 2016-04-24 19:46:41 +02:00
a23d9dfb25 Fixed #18 2016-04-24 17:45:13 +02:00
53d8567148 Added /tableflip, /unflip, /chatonly and the ability to unlaugh the console 2016-04-24 17:29:08 +02:00
e8ebd8c41e idk 2016-04-21 22:05:44 +02:00
b0f9c9150d idk 2016-04-21 22:04:45 +02:00
e922c31a0b idk 2016-04-21 22:03:58 +02:00
ea62fd93e5 Update .gitignore 2016-04-21 22:02:03 +02:00
89387d534b idc 2016-04-21 22:00:38 +02:00
ddb53c9c18 Added JAR 2016-04-21 21:47:45 +02:00
8dc253564c Done #12 - Changed color setting 2016-04-21 21:46:28 +02:00
9300e59438 Fixed gitignore stuff 2016-04-21 21:35:35 +02:00
c9d66715f9 Removed files 2016-04-21 19:23:52 +02:00
3a881addd2 Rearranged stuff 2016-04-21 19:06:29 +02:00
09c076ec98 Stuff 2016-04-11 23:17:32 +02:00
4edf91cbeb Added Treavis stuff 2016-04-11 23:11:27 +02:00
798a901dd6 Fixed and updated things a bit 2016-04-11 23:03:17 +02:00
300eaa70b9 Merge branch 'master' of https://github.com/NorbiPeti/thebuttonautoflairmc 2016-04-11 22:58:12 +02:00
c6a19599e0 Did some stuff 2016-04-11 22:55:26 +02:00
d5f1ef24ac Merge pull request #11 from Sciguymjm/master
Added wartime tele check
2016-04-11 20:40:56 +02:00
c54a8e2a6d Probably fixed auto-login temp fix 2016-04-11 20:34:30 +02:00
Sciguymjm
1c65f95293 Added wartime tele check 2016-04-11 13:24:15 -04:00
343c838ca6 Added temp fix for login movement speed 0 2016-04-10 21:03:38 +02:00
7a2d11afa1 Fixed stuff 2016-04-10 02:25:10 +02:00
3d5893360c Added FastLogin permission control 2016-04-04 22:00:18 +02:00
945604a5d6 Added message for online players when they vote 2016-03-19 17:12:22 +01:00
1e01fe4e86 See prev. commit 2016-03-14 22:21:23 +01:00
b75db23057 Removed debug messages 2016-03-14 20:50:02 +01:00
eb9da1c520 Fixed name mentioning (missing sound) 2016-03-14 20:46:14 +01:00
9d33b7e21f Fixed chat for 1.9 ("How did this even work before") 2016-03-14 20:35:48 +01:00
80c0756ef7 Added missing permission check for color replacement in chat 2016-03-11 15:30:03 +01:00
91a1cbcbdc Workaround for Unknown command 2016-03-08 18:49:08 +01:00
0e55cf89da Invited @console to the party 2016-03-08 18:30:08 +01:00
aaf19190e4 Fixed NullPointerException in PlayerInteractEvent 2016-03-05 19:50:24 +01:00
05245c05f8 Made @console pingable 2016-02-29 21:26:14 +01:00
330ab45b95 Fixed interact event exception 2016-02-28 19:14:10 +01:00
1495685a13 Added enderchest protection for twohundred and fixed rainbow text :P 2016-02-28 18:47:28 +01:00
37ba5a5d5f Fixed /u <color> confirm message and rainbow colors 2016-02-28 17:00:20 +01:00
15c6a57979 Increased void teleporter area, added option to set message color 2016-02-28 15:59:08 +01:00
6d573a0d68 Fixed certain messages kicking players, fixed rainbow chat, added tbmc.rainbow permission 2016-02-27 21:10:02 +01:00
2007001562 Prevented setting NewHaven as enemy 2016-02-27 11:03:05 +01:00
377d6d9035 Added colored text with rainbow colors! 2016-02-27 00:32:33 +01:00
63929b7006 The Tower teleporter got moved to this plugin, fixed /mwiki, added teleport controlling, Fs are now divided by deaths 2016-02-26 23:40:31 +01:00
60620fb154 Fixed NPC death event 2016-02-22 19:01:02 +01:00
d22f2bee69 Added /mwiki - Added /un- with the tbmc.admin permission 2016-02-19 23:31:07 +01:00
8005f715c8 Merge branch 'master' of https://github.com/NorbiPeti/thebuttonautoflairmc
Merged with readme update
2016-01-31 11:34:52 +01:00
b67d2a9ef6 Allowing tp with /home and /tpa inside the minigame 2016-01-31 11:34:07 +01:00
4248f17b97 Updated Readme
Updated link and made a few fixes.
2016-01-30 21:20:50 +01:00
63a04d98da Fixed flying 2016-01-29 23:20:59 +01:00
73b8c0ce03 Allowed fly and teleport in 200 day minigame 2016-01-29 22:51:46 +01:00
14fbdaef55 Added game mechanic for 200 days build 2016-01-29 19:44:39 +01:00
a25a731e4d Fixed Nation Chat 2016-01-28 21:34:11 +01:00
e24a7b663e Changed flair thread URL 2016-01-28 17:50:49 +01:00
ade248bf90 Added laughs to unlaugh 2016-01-27 19:21:55 +01:00
4dc5004e7c Fixed double quotes and Tablist flairs 2016-01-27 18:25:49 +01:00
d5050d0c30 Added lmao to the unlaugh list (#6) 2016-01-25 21:49:09 +01:00
3c00e25719 Fixed Towny spy and did something to Votifier 2016-01-25 20:53:01 +01:00
668c02a1e8 Made the chat event respect cancellation, fixed \ escaping, added Votifier event 2016-01-23 22:15:57 +01:00
4fe8085de8 Fixed crash if Resident is null at /sethome 2016-01-10 02:00:13 +01:00
47419c0925 Added code to prevent setting homes in enemy territory, changed commandpreprocess event priority to highest, implemented #5 2016-01-09 22:52:44 +01:00
5bbe8e12d5 Added laughs to /unlaugh and fixed it 2016-01-08 20:59:52 +01:00
3c3637f6ff Fixed chat quotes 2016-01-05 21:18:44 +01:00
8c8ad04725 Fixed quotes in chat messages 2016-01-05 21:01:03 +01:00
199f28ac06 Added /unlaugh and fixed /u ignore 2016-01-05 17:56:43 +01:00
e1e1ffe6b3 Added unlaugh and stuff 2016-01-02 00:31:16 +01:00
f99c0528dd Made flairs pernament 2016-01-01 19:47:23 +01:00
d30126e1cf Messages containing URLs won't be formatted to keep the original URL; clicking on the channel identifier (ex. [g]) will now copy the message. 2015-12-31 20:19:52 +01:00
d7be9fbe30 Added join date check when flair is unknown, implemented issue #3 and #4 2015-12-31 17:50:43 +01:00
29b3c8830a Mute fixed, re-enabled /minecraft:me except when muted, admin and mod channel added, links implemented 2015-12-31 17:32:54 +01:00
43ca6c1930 Removed debug message 2015-12-30 18:33:22 +01:00
8b1d70e30b Fixed /unlol 2015-12-30 14:48:57 +01:00
87a3d1e0cb Fixed /tc and /nc... 2015-12-30 14:19:58 +01:00
42fff2fbca Fixed town and nation chat... 2015-12-30 13:46:21 +01:00
93a4521293 Taken control over the chat with JSON formatting (/tellraw) 2015-12-30 13:31:59 +01:00
5a37aa5d74 Fixed a bug with handling tablist 2015-12-19 21:17:42 +01:00
afb35c06eb Added flair in tablist and done /unlol
- Added flair in tablist (idea taken from my command block version)
- Done /unlol
2015-12-19 13:42:04 +01:00
41618831dc Removed /u check from the wrong place 2015-12-09 20:44:56 +01:00
ffec31f75a Fixed name mentioning 2015-12-05 23:32:26 +01:00
b7e703fc2f Fixed non-presser/can't press auto-flair, added all usernames to playerinfo 2015-12-05 15:27:33 +01:00
edd3fbf8aa Merge branch 'master' of https://github.com/NorbiPeti/thebuttonautoflairm c
Readme and a bunch of stuff.
2015-12-04 23:52:45 +01:00
65aad75a14 Fixed stuff 2015-12-04 23:51:41 +01:00
b7da549712 Readme Update 2015-12-04 23:22:41 +01:00
ffbd560c26 Reworked flair system, made improvements 2015-12-04 23:07:21 +01:00
08398300f4 Removed folder from repository 2015-12-04 18:44:33 +01:00
c95c042925 Removed metadata folder from repository 2015-12-04 18:42:36 +01:00
3a00450e3e Tweaked KittyCannon 2015-11-28 16:13:33 +01:00
788e15a22d Fixed KittyCannon... 2015-11-28 01:31:34 +01:00
682af5c0a0 Fixed KittyCannon 2015-11-28 01:09:01 +01:00
77bc93d674 Added KittyCannon for the minigame 2015-11-27 22:03:38 +01:00
a321a8444d Fixed SavePos and LoadPos 2015-11-22 03:02:01 +01:00
abead0e7a7 Setting CommentedOnReddit even if the user didn't get a flair. 2015-11-20 23:02:22 +01:00
f319889f10 Fixed users not being able to ignore message after writing name in thread if the flair is unknown 2015-11-20 22:48:24 +01:00
7192234b18 ??? 2015-11-16 21:27:08 +01:00
55b2368c4c Gitignore stuff 2015-11-16 21:22:22 +01:00
4455b27659 Put the F message on a timer, instead of messages and also made some optimizations 2015-11-16 21:11:54 +01:00
bfb450b0fb Readme Update 2015-11-16 21:03:21 +01:00
5beca898d3 Improved message shown for people who haven't commented in the thread
- Changed to /tellraw
- Added a delay
2015-11-14 22:53:49 +01:00
98dd5eab64 Added basic quiz system, made announcements and questions editable from command blocks, and other fixes 2015-11-09 21:56:58 +01:00
62960dfe57 Fixed custom flairs not recognised 2015-10-31 22:08:09 +01:00
fadd7d6a7f Made hashtags only show up in global chat 2015-10-30 19:10:12 +01:00
41d820f92b Fixed F 2015-10-25 20:32:14 +01:00
0d72c9fd84 Switched to UUID-s and YAML
https://www.reddit.com/r/TheButtonMinecraft/comments/3p1zo7/
2015-10-17 02:06:32 +02:00
ae1505ec56 Added a tag in chat for players in wilds 2015-10-16 18:44:37 +02:00
62787ee81f Learned how Java works - Fixed hashtag formatting 2015-10-13 22:15:33 +02:00
dd5ddde46a Changed hashtag colors to be lighter 2015-10-05 20:08:31 +02:00
6d7aee5872 Added minigame detection to prevent F mesasges from showing 2015-10-03 22:51:22 +02:00
f66d3f5aac Fixed F counting, added hashtag support, made greentext work with names and hashtags 2015-10-03 19:28:03 +02:00
0cc6d040ec Added simple position saving/loading commands and removed network error output to reduce log spamming 2015-10-03 00:15:13 +02:00
afbe918005 Fixed the F thing and updated the event realted to it 2015-09-30 20:44:15 +02:00
3c57bfb1b0 Added support for lowercase F 2015-09-20 00:44:59 +02:00
dadad4cf1f Added check for duplicate names in tabcomplete and uploaded JAR 2015-09-19 12:36:18 +02:00
a16ab64a22 Cleaned up code and added F 2015-09-18 20:55:00 +02:00
cb44dccf56 Updated Readme 2015-09-16 22:35:24 +02:00
b98b7f202c Added License... 2015-09-10 22:06:26 +02:00
c48aaec8da Updated JAR with merged changes
Probably.
2015-09-08 21:28:05 +02:00
1292ce47c3 Improved nicknames (fixed color not resetting after name) 2015-09-08 21:23:33 +02:00
ed35a864e9 Merge pull request #2 from Sciguymjm/master
Added greentext support
2015-09-08 05:29:34 +01:00
M
a319ede0da Added greentext support 2015-09-07 15:54:11 -04:00
7a5d4ce0ff Fixed name highlighting 2015-09-05 10:05:52 +02:00
4cea49f0ad Changed chat formatting to support (and depend on) TownyChat 2015-09-04 20:16:24 +02:00
83c8379656 Changed "plugin/essentials/userdata/" to "plugin/Essentials/userdata/" 2015-09-04 17:39:24 +02:00
eab5ecb764 Added debug toggle command 2015-09-03 19:26:41 +02:00
760e8f63a2 Added debug code 2015-09-03 18:59:11 +02:00
cf18b4344c Changed non-RP to OOC and made RP tags hide/showable by OPs 2015-08-31 21:21:20 +02:00
0432bddaf4 Added some debug code 2015-08-31 08:40:37 +02:00
4641d5f919 Added ability to ignore the message about writing the playername to the thread 2015-08-29 01:14:35 +02:00
06c00a2ab8 Removed Reflection things (for /tellraw) becuase it caused issues on the server 2015-08-29 01:05:32 +02:00
5215d10748 Added username lookup command /u name 2015-08-29 01:05:30 +02:00
1d0a12666a Updated Readme
RP mode.
2015-08-25 16:42:56 +02:00
321e94af6c Added RP mode switcher commands (/rp /nrp)
- Added /rp and /nrp
- Added an indicator if the player speaks in RP or non-RP mode
2015-08-25 16:28:33 +02:00
e8d02565cb Removed debug code and made other stuff 2015-08-20 00:47:54 +02:00
d4fc9b8a9c Updated Readme 2015-08-20 00:36:18 +02:00
993fc663e2 Updated Readme 2015-08-19 22:25:24 +02:00
45b6969251 Added announce messages and made some fixes
- Added a bunch of commands (/u announce)
- Fixed some stuff
2015-08-19 21:30:27 +02:00
dc3e494a19 Fixes
- Fixed custom flair loading
- Added colored name handling for nicknames
- It will now remove nicknames on disconnect (so if the nickname gets
changed, a relog will make the changes in name mentioning)
2015-08-19 11:40:47 +02:00
5a048c4486 Merge pull request #1 from Sciguymjm/master
Clean up code and add nickname support
2015-08-19 09:00:14 +01:00
Sciguymjm
77d08fc406 Fixed .gitignore 2015-08-18 19:14:20 -04:00
Sciguymjm
7e6eb5e27f Added nickname integration 2015-08-18 19:09:16 -04:00
832a1a0b4e JARUp 2015-08-17 10:30:40 +02:00
23fbeda5ef Undone a change 2015-08-17 10:28:38 +02:00
d2f6a5ef07 Removed some debug code, added colors by flair color to name mentioning, etc.
- Removed some debug code
- Added name coloring by flair color when using name mentioning
- Fixed custom flair saving
- Added a check for /u admin setflair to only allow flairs starting with
a color code
- Updated version number (2.0)
- Updated plugin name
2015-08-17 10:28:37 +02:00
ce58b842e7 Removed note from Readme 2015-08-15 11:19:32 +02:00
b66c8f1214 I've hidden the "Added new flair" text in console. 2015-08-14 21:15:15 +02:00
42b85a3e0c Updated Readme
Clarified out of date plugin.
2015-08-14 19:40:49 +02:00
15fdc3610a Updated Readme 2015-08-14 15:09:35 +02:00
365027586e Renamed plugin 2015-08-14 15:05:51 +02:00
216e1e0a2e Updated Readme 2015-08-14 14:42:51 +02:00
65a37fe704 Created Readme. WIP 2015-08-14 14:32:25 +02:00
5e48fc31c8 Added a way to customize the sound on name mentioning
You can create a file named "notificationsound.txt" and put a sound name
in the correct format which /playsound uses and the pitch after that.

For example:
mob.pig.say 1.0
2015-08-14 12:51:51 +02:00
98e0610da4 Uploaded the JAR - I really need a reminder 2015-08-12 16:35:37 +02:00
3ed0d39c06 Name mentioning + Some fixes about message coloring
- Added console color support for messages
- Added gold color for name mentioning
- Changed some colors
- Added sound when mentioning names
2015-08-12 13:52:27 +02:00
ede84612d4 Gitignore 2015-08-10 22:55:50 +02:00
5d08552a7c Gitignore 2015-08-10 22:52:42 +02:00
c075ef890a Bug fixes
- Fixed admin commands not working in certain cases
- Fixed custom flair saving
etc.
2015-08-10 22:47:05 +02:00
543e7c3d7e Finally fixed(?) the undecided case 2015-08-10 21:29:09 +02:00
9a4677da5b Actually fixed the case when the flair is undecided 2015-08-10 21:09:50 +02:00
2a6d6265d8 Added FlairDecided to /u admin playerinfo 2015-08-10 20:50:36 +02:00
df2c2bc1ba Added gitignore 2015-08-10 20:40:03 +02:00
9da95a61e0 Roughly same as before 2015-08-10 20:38:52 +02:00
7958bc17d3 Commented debug lines 2015-08-10 20:29:14 +02:00
691f247cc6 Fixed comment parsing 2015-08-10 20:22:29 +02:00
82d6f40173 Stuff 2015-08-10 16:44:31 +02:00
34e3c2608d Added updater
- It can now update itself with /u admin updateplugin and after a
reload, the new plugin will work
2015-08-10 16:38:42 +02:00
a85f536636 Forgot the JAR... Again
Uploading the JAR of the bugfixes, and also adding more bugfixes!
2015-08-10 11:31:42 +02:00
d5b6981ec7 Bug fixes
- Commented out WIP code which caused errors
- Other fixes
2015-08-10 07:45:50 +02:00
ec76a27bdd I forgot some stuff, including the JAR 2015-08-10 00:31:17 +02:00
f92b7d0f3d Lot of admin commands, bug fixes, and custom flairs
- Added many admin commands (see /u admin)
- Probably fixed the flairs for some players
- Added support for custom flairs, also used when deciding unknown flair
types
2015-08-10 00:28:15 +02:00
c60db397c8 Forgot to update the JAR 2015-08-09 16:35:51 +02:00
f82f4edbfa Added getplayerinfo, getlastexception, I can use op commands of this plugin
Added getplayerinfo, getlastexception, I can use op commands of this
plugin
2015-08-09 16:34:04 +02:00
8de31369f8 Added can't press flair, OO, compatible with Essentials
- Added can't press flair
- Made an object, instead of many Maps
- Using chat formatting instead of display names
2015-08-08 22:58:45 +02:00
5c06f4b809 Added a /tellraw message for new players to write their name on Reddit if they want it displayed. 2015-07-20 19:52:56 +02:00
a8af0c0ee6 Added support for name coloring by town (using Towny).
Write the town name to autoflairconfig.txt followed by the color codes.

Example:
test §2§5 will give me §2Norbi§r§5Peti§r

Also made some bugfixes.
2015-07-20 18:23:02 +02:00
760c238f16 Fixed a case when there is press time (-1) but there isn't any flair class. 2015-07-19 09:15:42 +02:00
6786e63fc1 Uploaded to fix user issues caused by wrong E-mail 2015-07-16 21:37:47 +02:00
386 changed files with 5814 additions and 40368 deletions

19
.editorconfig Normal file
View file

@ -0,0 +1,19 @@
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = false
indent_style = space
indent_size = 4
[*.json]
indent_style = space
indent_size = 2
[*.java]
indent_style = tab
tab_width = 4
[{*.yml, *.yaml}]
indent_style = space
indent_size = 2

221
.gitignore vendored Normal file
View file

@ -0,0 +1,221 @@
#################
## Eclipse
#################
*.pydevproject
.metadata/
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
target/
.project
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath
#################
## Visual Studio
#################
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.scc
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
*.ncrunch*
.*crunch*.local.xml
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.Publish.xml
*.pubxml
*.publishproj
# NuGet Packages Directory
## TO!DO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/
# Windows Azure Build Output
csx
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
#############
## Windows detritus
#############
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#############
## Python
#############
*.py[cod]
# Packages
*.egg
*.egg-info
dist/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
#Translations
*.mo
#Mr Developer
.mr.developer.cfg
.metadata/*
TheButtonAutoFlair/out/artifacts/Autoflair/Autoflair.jar
*.iml
*.name
.idea/compiler.xml
*.xml
/.apt_generated/

View file

@ -1,22 +0,0 @@
!SESSION 2015-07-15 15:24:45.371 -----------------------------------------------
eclipse.buildId=M20130204-1200
java.version=1.8.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=hu_HU
Framework arguments: -product org.eclipse.epp.package.jee.product -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product -data D:\Z - Norbi cucca\0 Projektek\TheButtonMCAutoFlairProto\Spigot plugin -product org.eclipse.epp.package.jee.product
!ENTRY org.eclipse.egit.ui 2 0 2015-07-15 15:25:41.331
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
this system level configuration. The Git installation location can be configured on the
Team > Git > Configuration preference page's 'System Settings' tab.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!ENTRY org.eclipse.egit.ui 2 0 2015-07-15 15:25:41.332
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Norbi'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

Binary file not shown.

Binary file not shown.

View file

@ -1,48 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,73 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
{
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
PluginMain.AcceptedPlayers.add(player.getName());
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
player.sendMessage("§6Your flair has been set:§r "+flair);
}
else
player.sendMessage("§cYou already have this user's flair.§r");
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
{
String dname=player.getDisplayName();
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
}
else
player.sendMessage("§cYou already ignored this request.§r");
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,27 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerLeaveEvent event)
{
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,37 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
PluginMain.AcceptedPlayers.add(player.getName());
player.setDisplayName(player.getDisplayName()+PluginMain.PlayerFlairs.get(player.getName()));
break;
case "ignore":
PluginMain.IgnoredPlayers.add(player.getName());
break;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,41 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
PluginMain.AcceptedPlayers.add(player.getName());
player.setDisplayName(player.getDisplayName()+PluginMain.PlayerFlairs.get(player.getName()));
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
PluginMain.IgnoredPlayers.add(player.getName());
break;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,61 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
{
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
PluginMain.AcceptedPlayers.add(player.getName());
player.sendMessage("§6Your flair has been set:§r "+flair);
}
else
player.sendMessage("$cYou already have this flair.§r");
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
{
PluginMain.IgnoredPlayers.add(player.getName());
String dname=player.getDisplayName();
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
}
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,16 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.util.function.Predicate;
public class MyPredicate<T> implements Predicate<T>
{
public MyPredicate(T first)
{
}
@Override
public boolean test(T second) {
return false;
}
}

View file

@ -1,63 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
{
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
PluginMain.AcceptedPlayers.add(player.getName());
player.sendMessage("§6Your flair has been set:§r "+flair);
}
else
player.sendMessage("$cYou already have this flair.§r");
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
{
PluginMain.IgnoredPlayers.add(player.getName());
String dname=player.getDisplayName();
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
}
else
player.sendMessage("§cYou already ignored this request.§r";)
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,63 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
{
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
PluginMain.AcceptedPlayers.add(player.getName());
player.sendMessage("§6Your flair has been set:§r "+flair);
}
else
player.sendMessage("$cYou already have this flair.§r");
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
{
PluginMain.IgnoredPlayers.add(player.getName());
String dname=player.getDisplayName();
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
}
else
player.sendMessage("§cYou already ignored this request.§r");
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,21 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerListener implements Listener
{
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,244 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,254 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,50 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
String dname=player.getDisplayName();
player.setDisplayName(.substring(0, dname));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,285 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
File file=new File("flairsaccepted.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
}
file=new File("flairsignored.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
String line;
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
}
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
try
{
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
}
catch
{
}
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,43 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player p=event.getPlayer();
PluginMain.Players.add(p);
event.getPlayer().setDisplayName(p.getDisplayName()+PluginMain.GetFlair(p));
System.out.println("Added player "+event.getPlayer().getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName()==event.getPlayer().getName())
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,31 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
for(Player player : PluginMain.Players)
{
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,41 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
PluginMain.AcceptedPlayers.add(player.getName());
player.setDisplayName(player.getDisplayName()+PluginMain.PlayerFlairs.get(player.getName()));
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
PluginMain.AcceptedPlayers.add(player.getName());
break;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,47 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,17 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.util.function.Predicate;
public class MyPredicate<T> implements Predicate<T>
{
private T First;
public MyPredicate(T first)
{
First=first;
}
@Override
public boolean test(T second) {
return false;
}
}

View file

@ -1,32 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
PluginMain.Players.removeIf({
public boolean test()
event.getPlayer().getName()
});
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,47 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,265 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : AcceptedPlayers)
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,41 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
PluginMain.AcceptedPlayers.add(player.getName());
player.setDisplayName(player.getDisplayName()+PluginMain.PlayerFlairs.get(player.getName()));
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
PluginMain.IgnoredPlayers.add(player.getName());
break;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,45 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
player.setDisplayName(player.getDisplayName()+PluginMain.PlayerFlairs.get(player.getName()));
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,42 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
player.setDisplayName(player.getDisplayName()+PluginMain.PlayerFlairs.get(player.getName()));
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
PluginMain.IgnoredPlayers.add(player.getName());
break;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,278 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
File file=new File("flairsaccepted.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
}
file=new File("flairsignored.txt");
if(file.exists())
{
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
}
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,16 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.util.function.Predicate;
public class MyPredicate<T> implements Predicate<T>
{
public MyPredicate<T>()
{
}
@Override
public boolean test(T arg0) {
return false;
}
}

View file

@ -1,11 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3

View file

@ -1,32 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
PluginMain.Players.removeIf({
public boolean
event.getPlayer().getName()
});
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,280 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
File file=new File("flairsaccepted.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
}
file=new File("flairsignored.txt");
if(file.exists())
{
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
if(file.exists())
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,263 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
return;
}
if(AcceptedPlayers.contains(player.getName()))
{
player.setDisplayName(player.getDisplayName()+flair);
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,37 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
System.out.println("Added player "+event.getPlayer().getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
for(Player player : PluginMain.Players)
{
if(player.getName()==event.getPlayer().getName())
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,41 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
System.out.println("Added player "+event.getPlayer().getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName()==event.getPlayer().getName())
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,17 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.util.function.Predicate;
public class MyPredicate<T> implements Predicate<T>
{
private T First;
public MyPredicate(T first)
{
}
@Override
public boolean test(T second) {
return false;
}
}

View file

@ -1,28 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
PluginMain.Players.remove(event.getPlayer());
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,43 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player p=event.getPlayer();
PluginMain.Players.add(p);
event.getPlayer().setDisplayName(p.getDisplayName()+PluginMain.GetFlair(p));
System.out.println("Added player "+p.getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName()==event.getPlayer().getName())
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,21 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,278 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
File file=new File("flairsaccepted.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
}
file=new File("flairsignored.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
}
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,32 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
for(Player player : PluginMain.Players)
{
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,44 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player p=event.getPlayer();
PluginMain.Players.add(p);
//event.getPlayer().setDisplayName(p.getDisplayName()+PluginMain.GetFlair(p));
System.out.println("Added player "+p.getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName().equals(event.getPlayer().getName()))
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,279 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
File file=new File("flairsaccepted.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
}
file=new File("flairsignored.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
String line;
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
}
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,277 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
File file=new File("flairsaccepted.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
}
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
if(file.exists())
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,274 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
File file=new File("flairsaccepted.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
}
file=new File("flairsignored.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
String line;
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
}
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,44 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player p=event.getPlayer();
PluginMain.Players.add(p);
//event.getPlayer().setDisplayName(p.getDisplayName()+PluginMain.GetFlair(p));
PluginMain.AppendPlayerDisplayFlair(p, PluginMain.GetFlair(p));
System.out.println("Added player "+p.getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName().equals(event.getPlayer().getName()))
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,36 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
PluginMain.AcceptedPlayers.add(player.getName());
player.setDisplayName(player.getDisplayName()+PluginMain.PlayerFlairs.get(player.getName()));
break;
case "ignore":
break;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,267 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsignored.txt", true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,262 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,28 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
PluginMain.Players.removeIf(new MyPredicate<Player>(event.getPlayer().getName()))
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,278 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
File file=new File("flairsaccepted.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
}
file=new File("flairsignored.txt");
if(file.exists())
{
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
}
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,12 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.util.function.Predicate;
public class MyPredicate<T> implements Predicate<T>
{
@Override
public boolean test(T arg0) {
return false;
}
}

View file

@ -1,47 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,262 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,263 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,19 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerListener implements Listener
{
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,278 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
File file=new File("flairsaccepted.txt");
if(file.exists())
{
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
}
file=new File("flairsignored.txt");
if(file.exists())
{
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
}
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,17 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.util.function.Predicate;
public class MyPredicate<T> implements Predicate<T>
{
private T First;
public MyPredicate(T first)
{
First=first;
}
@Override
public boolean test(T second) {
return First.equals(second);
}
}

View file

@ -1,46 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
player.setDisplayName(player.getDisplayName()+PluginMain.PlayerFlairs.get(player.getName()));
player.sendMessage("§6Your flair has been set.");
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,47 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,260 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
PluginMain.IgnoredPlayers.add(player.getName());
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,38 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
System.out.println("Added player "+event.getPlayer().getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
if(player.getName()==event.getPlayer().getName())
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,21 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerListener implements Listener
{
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,32 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
for(Player player : PluginMain.Players)
{
if(player.getName()==event.getPlayer().getName())
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,34 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
PluginMain.Players.removeIf({
public boolean test(T var)
{
return var==event.getPlayer().getName();
}
});
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,11 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5

View file

@ -1,261 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
BufferedReader br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,47 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,47 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,45 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
player.setDisplayName(player.getDisplayName()+PluginMain.PlayerFlairs.get(player.getName()));
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,48 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
case "ignore":
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
break;
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,44 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player p=event.getPlayer();
PluginMain.Players.add(p);
//event.getPlayer().setDisplayName(p.getDisplayName()+PluginMain.GetFlair(p));
PluginMain.AppendPlayerDisplayFlair(p, PluginMain.GetFlair(p));
System.out.println("Added player "+p.getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName().equals(event.getPlayer().getName()))
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,54 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.add(player.getName());
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
player.sendMessage("§6Your flair has been set:§r "+flair);
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
String dname=player.getDisplayName();
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,44 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player p=event.getPlayer();
PluginMain.Players.add(p);
//event.getPlayer().setDisplayName(p.getDisplayName()+PluginMain.GetFlair(p));
PluginMain.AppendPlayerDisplayFlair(p, PluginMain.GetFlair(p));
System.out.println("Added player "+p.getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName().equals(event.getPlayer().getName()))
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,44 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player p=event.getPlayer();
PluginMain.Players.add(p);
//event.getPlayer().setDisplayName(p.getDisplayName()+PluginMain.GetFlair(p));
PluginMain.AppendPlayerDisplayFlair(p, PluginMain.GetFlair(p));
System.out.println("Added player "+p.getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName().equals(event.getPlayer().getName()))
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,270 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");flairsaccepted
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt"File file=new File(
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,81 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
{
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
PluginMain.AcceptedPlayers.add(player.getName());
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
player.sendMessage("§6Your flair has been set:§r "+flair);
}
else
player.sendMessage("§cYou already have this user's flair.§r");
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
{
PluginMain.IgnoredPlayers.add(player.getName());
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
String dname=player.getDisplayName();
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
}
else
player.sendMessage("§cYou already ignored this request.§r");
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,28 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
PluginMain.Players.removeIf(event.getPlayer().getName());
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,74 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
{
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
PluginMain.AcceptedPlayers.add(player.getName());
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
player.sendMessage("§6Your flair has been set:§r "+flair);
}
else
player.sendMessage("§cYou already have this user's flair.§r");
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
{
PluginMain.IgnoredPlayers.add(player.getName());
String dname=player.getDisplayName();
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
}
else
player.sendMessage("§cYou already ignored this request.§r");
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,59 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
{
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
PluginMain.AcceptedPlayers.add(player.getName());
player.sendMessage("§6Your flair has been set:§r "+flair);
}
else
player.sendMessage("$cYou already have this flair.§r");
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.add(player.getName());
String dname=player.getDisplayName();
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,44 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player p=event.getPlayer();
PluginMain.Players.add(p);
//event.getPlayer().setDisplayName(p.getDisplayName()+PluginMain.GetFlair(p));
PluginMain.AppendPlayerDisplayFlair(p, PluginMain.GetFlair(p));
System.out.println("Added player "+p.getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName().equals(event.getPlayer().getName()))
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,270 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt"File file=new File(
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,267 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : AcceptedPlayers)
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,43 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Player p=event.getPlayer();
PluginMain.Players.add(p);
event.getPlayer().setDisplayName(event.getPlayer().getDisplayName()+PluginMain.GetFlair(event.getPlayer()));
System.out.println("Added player "+event.getPlayer().getName());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
//for(Player player : PluginMain.Players)
for(int i=0; i<PluginMain.Players.size();)
{
Player player=PluginMain.Players.get(i);
if(player.getName()==event.getPlayer().getName())
{
PluginMain.Players.remove(player);
System.out.println("Removed player "+event.getPlayer().getName());
}
else
i++; //If the player is removed, the next item will be on the same index
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,270 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,35 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event)
{
for(Player player : PluginMain.Players)
{
if(player.getName()==event.getPlayer().getName())
{
PluginMain.Players.remove(player);
}
}
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,21 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerListener implements Listener
{ //2015.07.16.
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
PluginMain.Players.add(event.getPlayer());
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,260 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
try {
BufferedWriter bw=new BufferedWriter(new FileWriter("flairsaccepted.txt", true));
bw.write(player.getName()+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

View file

@ -1,67 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
{
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
PluginMain.AcceptedPlayers.add(player.getName());
player.sendMessage("§6Your flair has been set:§r "+flair);
}
else
player.sendMessage("§cYou already have this user's flair.§r");
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
PluginMain.IgnoredPlayers.add(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
{
String dname=player.getDisplayName();
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
}
else
player.sendMessage("§cYou already ignored this request.§r");
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,16 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.util.function.Predicate;
public class MyPredicate<T> implements Predicate<T>
{
public MyPredicate()
{
}
@Override
public boolean test(T arg0) {
return false;
}
}

View file

@ -1,63 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length<1)
return false;
if(!PluginMain.PlayerFlairs.containsKey(player.getName()))
{
player.sendMessage("Error: You need to write your username to the reddit thread at /r/TheButtonMinecraft");
return true;
}
switch(args[0])
{
case "accept":
{
if(PluginMain.IgnoredPlayers.contains(player.getName()))
PluginMain.IgnoredPlayers.remove(player.getName());
if(!PluginMain.AcceptedPlayers.contains(player.getName()))
{
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(player.getDisplayName()+flair);
PluginMain.AcceptedPlayers.add(player.getName());
player.sendMessage("§6Your flair has been set:§r "+flair);
}
else
player.sendMessage("§cYou already have this user's flair.§r");
break;
}
case "ignore":
{
if(PluginMain.AcceptedPlayers.contains(player.getName()))
PluginMain.AcceptedPlayers.remove(player.getName());
if(!PluginMain.IgnoredPlayers.contains(player.getName()))
{
PluginMain.IgnoredPlayers.add(player.getName());
String dname=player.getDisplayName();
String flair=PluginMain.PlayerFlairs.get(player.getName());
player.setDisplayName(dname.substring(0, dname.indexOf(flair)));
player.sendMessage("§6You have ignored this request. You can still use /u accept though.§r");
}
else
player.sendMessage("§cYou already ignored this request.§r");
break;
}
default:
return false;
}
return true;
}
// If the player (or console) uses our command correct, we can return true
return false;
}
}

View file

@ -1,20 +0,0 @@
package tk.sznp.thebuttonautoflair;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class PlayerListener implements Listener
{
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event)
{
}
}

View file

@ -1,273 +0,0 @@
package tk.sznp.thebuttonautoflair;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.JSONArray;
import org.json.JSONObject;
public class PluginMain extends JavaPlugin
{ //Translated to Java: 2015.07.15.
//A user, which flair isn't obtainable:
//https://www.reddit.com/r/thebutton/comments/31c32v/i_pressed_the_button_without_really_thinking/
// Fired when plugin is first enabled
@Override
public void onEnable()
{
System.out.println("The Button Auto-flair Plugin by NorbiPeti (:P)");
//System.out.println("Original C# version: http://pastebin.com/tX8xCPbp");
//System.out.println("The Java version is... Also made by the same person.");
//System.out.println("With the help of StackOverflow and similar.");
/*catch(MalformedURLException e)
{
}
catch(IOException e)
{
}*/
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
//System.out.println("Registering commands...");
this.getCommand("u").setExecutor(new Commands());
this.getCommand("u").setUsage(this.getCommand("u").getUsage().replace('&', '§'));
try {
BufferedReader br=new BufferedReader(new FileReader("flairsaccepted.txt"));
String line;
while ((line = br.readLine()) != null)
{
AcceptedPlayers.add(line.replace("\n", ""));
}
br.close();
br=new BufferedReader(new FileReader("flairsignored.txt"));
while ((line = br.readLine()) != null)
{
IgnoredPlayers.add(line.replace("\n", ""));
}
br.close();
FileWriter fw;
fw = new FileWriter("flairsaccepted.txt");
fw.close();
fw = new FileWriter("flairsignored.txt");
fw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
//System.out.println("Registering done.");
Runnable r=new Runnable(){public void run(){ThreadMethod();}};
Thread t=new Thread(r);
t.start();
}
Boolean stop=false;
// Fired when plugin is disabled
@Override
public void onDisable()
{
for(String player : AcceptedPlayers)
{
File file=new File("flairsaccepted.txt");
if(file.exists())
{
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
}
for(String player : IgnoredPlayers)
{
File file=new File("flairsignored.txt");
try {
BufferedWriter bw=new BufferedWriter(new FileWriter(file, true));
bw.write(player+"\n");
bw.close();
} catch (IOException e) {
System.out.println("Error!\n"+e);
}
}
stop=true;
}
public void ThreadMethod() //<-- 2015.07.16.
{
while(!stop)
{
try
{
String body=DownloadString("https://www.reddit.com/r/TheButtonMinecraft/comments/3d25do/autoflair_system_comment_your_minecraft_name_and/.json?limit=1000");
JSONArray json=new JSONArray(body).getJSONObject(1).getJSONObject("data").getJSONArray("children");
for(Object obj : json)
{
JSONObject item = (JSONObject)obj;
String author=item.getJSONObject("data").getString("author");
String ign=item.getJSONObject("data").getString("body");
int start = ign.indexOf("IGN:") + "IGN:".length();
int end = ign.indexOf(' ', start);
if (end == -1 || end == start)
end=ign.indexOf('\n', start); //2015.07.15.
if (end == -1 || end == start)
ign = ign.substring(start);
else
ign = ign.substring(start, end);
ign = ign.trim();
if(HasIGFlair(ign))
continue;
//System.out.println("Author: "+author);
try {
Thread.sleep(10);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
String[] flairdata = DownloadString("http://karmadecay.com/thebutton-data.php?users=" + author).replace("\"", "").split(":");
String flair;
if(flairdata.length > 1) //2015.07.15.
flair = flairdata[1];
else
flair="";
if (flair != "-1")
flair = flair + "s";
else
flair = "non-presser";
String flairclass;
if(flairdata.length>1)
flairclass = flairdata[2];
else
flairclass="unknown";
SetFlair(ign, flair, flairclass, author);
}
Thread.sleep(10000);
}
catch(Exception e)
{
System.out.println("Error!\n"+e);
}
}
}
public String DownloadString(String urlstr) throws MalformedURLException, IOException
{
URL url = new URL(urlstr);
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "TheButtonAutoFlair");
InputStream in = con.getInputStream();
String encoding = con.getContentEncoding();
encoding = encoding == null ? "UTF-8" : encoding;
String body = IOUtils.toString(in, encoding);
in.close();
return body;
}
//It has to store offline player flairs too, therefore it can't use Player object
public static Map<String, String> PlayerFlairs=new HashMap<String, String>();
public static Map<String, String> PlayerUserNames=new HashMap<String, String>();
//public Map<Player, String> PlayerFlairs=new HashMap<Player, String>();
public static ArrayList<Player> Players=new ArrayList<Player>();
public static ArrayList<String> AcceptedPlayers=new ArrayList<String>(); //2015.07.16.
public static ArrayList<String> IgnoredPlayers=new ArrayList<String>(); //2015.07.16.
public Boolean HasIGFlair(String playername)
{
/*Player player=null;
for(Player p : Players)
{
if(p.getName()==playername)
{
player=p;
break;
}
}
if(player==null)
return false;*/
return PlayerFlairs.containsKey(playername);
}
public void SetFlair(String playername, String text, String flairclass, String username)
{
String finalflair;
switch(flairclass)
{
case "press-1":
finalflair="§c("+text+")§r";
break;
case "press-2":
finalflair="§6("+text+")§r";
break;
case "press-3":
finalflair="§e("+text+")§r";
break;
case "press-4":
finalflair="§a("+text+")§r";
break;
case "press-5":
finalflair="§9("+text+")§r";
break;
case "press-6":
finalflair="§5("+text+")§r";
break;
case "no-press":
finalflair="§7(non-pr.)§r";
break;
case "cheater":
finalflair="§5("+text+")§r";
break;
default:
finalflair="";
break;
}
PlayerFlairs.put(playername, finalflair);
PlayerUserNames.put(playername, username);
/*for(Player player : Players)
{
if(player.getName()==playername)
{
PlayerFlairs.put(player, finalflair);
break;
}
}*/
//System.out.println("SetFlair - playername: "+playername+" text: "+text+" flairclass: "+flairclass);
System.out.println("Added new flair to "+playername+": "+finalflair);
for(Player player : Players)
{
//System.out.println("Online player: "+player.getName());
//System.out.println("player.getName ("+player.getName()+") == playername ("+playername+"): "+(player.getName()==playername));
if(player.getName().equals(playername))
{
//System.out.println("DisplayName: "+player.getDisplayName());
//player.setDisplayName(player.getDisplayName()+finalflair);
AppendPlayerDisplayFlair(player, username, finalflair);
//System.out.println("DisplayName: "+player.getDisplayName());
break;
}
}
}
public static String GetFlair(Player player)
{ //2015.07.16.
String flair=PlayerFlairs.get(player.getName());
return flair==null ? "" : flair;
}
public static void AppendPlayerDisplayFlair(Player player, String username, String flair)
{
if(IgnoredPlayers.contains(player.getName()))
return;
if(AcceptedPlayers.contains(player.getName()))
player.setDisplayName(player.getDisplayName()+flair);
else
player.sendMessage("§9Are you Reddit user "+username+"?§r §6Type /u accept or /u ignore§r");
}
}

Some files were not shown because too many files have changed in this diff Show more